Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Byte Array of SVG to Image file

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Byte Array of SVG to Image file

    Hello,

    I have created byte array in the memory of some SVG image. (source of byte array :: The APIs are third party api interfaced with C objects. so all I have received though this JNI APIs is the byte array.)

    I would like to convert byte array to SVG or PNG file. Please remember that input is already defined as SVG image's byte array.

    Please let me know if anyone has already solved this puzzle.

    final byte[] imagebytes = getValueAsByteArray(streamId); // This call is third party API call nothing much can be done. imgebytes are of SVG type

    Would like to create image file (SVG, PNG etc) from the above input.

    --- Update ---

    More progress ---

    when I print the bytearray this is what it shows me :--
    <?xml version="1.0" standalone="no"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
    <svg width="16mm" height="18mm" viewBox="0 0 1639 1800" xmlns="http://www.w3.org/2000/svg">
    <desc>Image produced by Accelrys Accord Chemistry SDK</desc>
    <g>
    <line x1="299.99" y1="599.97" x2="299.99" y2="1199.93" stroke="rgb(0,0,0)" stroke-width="18.00"/>
    <line x1="299.99" y1="1199.93" x2="819.59" y2="1499.91" stroke="rgb(0,0,0)" stroke-width="18.00"/>
    <line x1="819.59" y1="1499.91" x2="1339.20" y2="1199.93" stroke="rgb(0,0,0)" stroke-width="18.00"/>
    <line x1="1339.20" y1="1199.93" x2="1339.20" y2="599.97" stroke="rgb(0,0,0)" stroke-width="18.00"/>
    <line x1="1339.20" y1="599.97" x2="819.59" y2="299.99" stroke="rgb(0,0,0)" stroke-width="18.00"/>
    <line x1="819.59" y1="299.99" x2="299.99" y2="599.97" stroke="rgb(0,0,0)" stroke-width="18.00"/>
    </g>
    </svg>


    I have convert the above data into SVG format.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Byte Array of SVG to Image file

    Have not used it myself, but see
    Apache(tm) Batik SVG Toolkit - a Java-based toolkit for applications or applets that want to use images in the Scalable Vector Graphics (SVG)
    Don't know about the IO utils of this library, but on quick inspection you could probably render the SVG inside a Component, if you wish to convert to an image then paint the component using the Graphics of a BufferedImage.

Similar Threads

  1. [SOLVED] [Asking] Convert String to Byte Array
    By ardisamudra in forum Java Theory & Questions
    Replies: 8
    Last Post: October 30th, 2012, 09:58 AM
  2. Problem recreating an image from a byte array
    By Kalelovil in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 19th, 2012, 01:17 AM
  3. Replies: 0
    Last Post: June 19th, 2011, 02:16 AM
  4. How Convert a Byte array to a image format
    By perlWhite in forum Algorithms & Recursion
    Replies: 7
    Last Post: February 19th, 2011, 03:16 PM
  5. Convert Vector to Byte Array
    By perlWhite in forum Java Theory & Questions
    Replies: 0
    Last Post: August 25th, 2009, 05:45 AM

Tags for this Thread