Converting a PNG image to an array of bytes and vice versa..

hi all,
i need to convert a PNG image to an array of bytes ,then converting back this array of bytes to The PNG image again ,i read this can be done using output streams but i feel like a dump and i can't fix the whole thingy out ! ,can anybody help me in this ,by explaining how can this be established????
Regards,
D.Roth

hi all,
i need to convert a PNG image to an array of bytes ,then converting back this array of bytes to The PNG image again ,i read this can be done using output streams but i feel like a dump and i can't fix the whole thingy out ! ,can anybody help me in this ,by explaining how can this be established????
Regards,
D.Roth

Similar Messages

  • How to convert SOAPEnvelope or SOAPBody to org.w3c.dom.Node and vice versa?

    How to convert javax.xml.soap.SOAPEnvelope or javax.xml.soapSOAPBody to org.w3c.dom.Node and vice versa?If this convertion is very diffcult , how to convert String to org.w3c.dom.Node?
    Thanks a lot

    vj008 wrote:
    while parsing a DOM i want to convert
    org.w3c.dom.Element to xml string and after certain processing on that xml string i want to convert back it to
    org.w3c.dom.Element.[This might help. xml transformations in java. |http://tejaspurohit.blogspot.com/2009/08/xml-transformations-in-java.html]

  • PDF to Word.doc Converter and vice versa

    Hello!
    I am in need of a program capable to convert PDF files to Word documents and vice versa (eventually, a program for each way). The converter needs GUI and must handle images, tables etc. (not just plain text). Does anyone have any tip concering which
    program I should use? It has to be free as my working place has not budgeted with buying 100 licenses. :-)
    Thanks in advance!

    Free? You'll be lucky. Your best bet to achieve your requirements is a PDF compatible OCR application such as Finereader. Free it ain't!
    <IKT-kr> wrote in message news:[email protected]...
    Hello!
    I am in need of a program capable to convert PDF files to Word documents and vice versa (eventually, a program for each way). The converter needs GUI and must handle images, tables etc. (not just plain text). Does anyone have any tip concering which program
    I should use? It has to be free as my working place has not budgeted with buying 100 licenses. :-)
    Thanks in advance!
    Graham Mayor - Word MVP
    www.gmayor.com
    Posted via the Communities Bridge
    http://communitybridge.codeplex.com/

  • How to convert ascii value into character and vice versa

    Hello the java world people,
    I want to convert each characters from my array into their corespondent ascii value and vice versa, how can I do that ?

    The term "ASCII" is often used very loosely.
    Java char values are UNICODE and the ASCII codes are indentical to UNICODE characters in the range 0 .. 127. UNICODE values 128 and above don't have coresponding ASCII values, though 128-255 corespond to ISO-8859-1 which is one of the encodings often called "extended ASCII".
    As shown above you can covert between chars and coresponding int value simply with a cast, but you should be aware that the more exotic characters will not give you sensible values.

  • Convert char to ascii code and vice versa

    HI
    Is there any function module to convert char to ascii code and vice versa.
    Thanks in advance

    Hi,
    be careful if you have unicode running in your system. URL_ASCII_CODE_GET is platform-dependent so it will return the internal HERX representation of the character in your system - which is hopefully and in most cases ASCII.
    Under unicode, we use double-byte characters here. I tried this function and the result CHAR_CODE is '00' regardless what character I specify for TRANS_CHAR. But the coding is so simple I corrected resultig in this sample code:
    [P]
    convert p_form to ASCII (internal) representation
      DATA:
        l_ofs TYPE syfdpos,
        l_len TYPE sy-linsz,
        l_ascii TYPE i.
      FIELD-SYMBOLS:
        <x> TYPE x.
      l_len = STRLEN( p_ascii ).
      DO l_len TIMES.
        l_ofs = sy-index - 1.
        ASSIGN p_ascii+l_ofs(1) TO <x> CASTING.
        l_ascii = <x>.
        WRITE: l_ascii.
      ENDDO.
    [/P]
    Here, for each character of string p_ascii, the internal (ASCII) representation is determined and written to the output list.
    Regards,
    Clemens

  • How to convert a data set into a xml data and vice versa

    i am new to oracle with xml..
    my aim is to convert a data set into a xml data and vice versa..
    my work is as follows...
    my query:
    select rggpk,rggcode,rggname from ms_regiongeo
    to convert a data set into a xml*
    select XMLType(trim(replace(dbms_xmlgen.getXML('select rggpk,rggcode, rggname from ms_regiongeo'),'<?xml version="1.0"?>',''))) XML_DATA from dual;
    (this works fine and output of this query is as follows..)
    <ROWSET>
    <ROW>
      <RGGPK>201</RGGPK>
      <RGGCODE>Asia</RGGCODE>
      <RGGNAME>Asia</RGGNAME>
    </ROW>
    <ROW>
      <RGGPK>1</RGGPK>
      <RGGCODE>OTH</RGGCODE>
      <RGGNAME>Others</RGGNAME>
    </ROW>
    <ROW>
      <RGGPK>21</RGGPK>
      <RGGCODE>COB</RGGCODE>
      <RGGNAME>Africa and Yemen</RGGNAME>
    </ROW>
    <ROW>
      <RGGPK>2</RGGPK>
      <RGGCODE>AUS</RGGCODE>
      <RGGNAME>Australia</RGGNAME>
    </ROW>
    <ROW>
      <RGGPK>23</RGGPK>
      <RGGCODE>IND</RGGCODE>
      <RGGNAME>Indian Sub Continent</RGGNAME>
    </ROW>
    <ROW>
      <RGGPK>24</RGGPK>
      <RGGCODE>TVM</RGGCODE>
      <RGGNAME>North America</RGGNAME>
    </ROW>
    </ROWSET>
    and to reverse this process, I tried a query like this..*
    select EXTRACTVALUE (XML_DATA,'ROWSET/ROW/RGGPK') as EMP_ID
    from(
            select XMLType(trim(replace(dbms_xmlgen.getXML('select rggpk,rggcode, rggname from ms_regiongeo'),'<?xml version="1.0"?>',''))) XML_DATA from dual
    )tab1but failed.. and raised with an eror: ORA-19025
    help me..
    regards,
    john

    Hi-
    my aim is to convert a data set into a xml data  You can refer to the below posts
    Adding namespace to XML output
    Re: how to convert table data in xml format based on the xsd.

  • How to convert from UNICODE (UTF16) to UTF8 and vice-versa in JAVA.

    Hi
    I want to insert a string in format UTF16 to the database. How do I convert from UTF16 to UTF8 and vice- versa in JAVA?. What type must the database field be? Do I need a special set up for the database (oracle 8.i)?
    thanks
    null

    I'm not sure if this is the correct topic, but we are having problems accessing our Japanese data stored in UTF-8 in our Oracle database using the JDBC thin driver. The data is submitted and extracted correctly using ODBC drivers, but inspection of the same data retrieved from the GetString() call using the JDBC thin driver shows frequent occurrences of bytes like "FF", which are not expected in either UTF8 or UCS2. My understanding is that accessing UTF8 in Java should involve NO NLS translation, since we are simply going from one Unicode encoding to another.
    We are using Oracle version 8.0.4.
    Can you tell me what we are doing wrong?
    null

  • How to convert 24bits png image into 8 bits image

    Hi,
    I have gone through some of threads in this forum on changing color bits. But, I still can find right way to change my image (24bits) into different color bits(8 bits). The reason i want to change the color bits because I am getting a GIF image from map server, convert it into PNG format then rescale then into size of mobile phone screen.The PNG image is really has large data length , so the it took a while to load the whole image on screen.
    Note : The following code is taken from few threads in this forum and i have modified it to suit my application.
    I have no idea about Java2d...any help really appreciated...Thanks in advance!!!
    My code is as follow:-
    public File Scale(int width, int height, BufferedImage ImgSrc)
         try
                   //BufferedImage bi = ImageIO.read(ImgSrc);
                   //int w = bi.getWidth(), h = bi.getHeight();
         //Image oldRescale = bi.getScaledInstance(i, j, Image.SCALE_SMOOTH);
         BufferedImage Rescale = rescale(ImgSrc, width, height);
                   //ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
                   //ColorConvertOp op = new ColorConvertOp(cs, null);
                   //Rescale = op.filter(Rescale, null);
         File outfile = new File("map.png");
                   ImageIO.write(Rescale, "png", outfile);
                   BufferedImage fromFile = ImageIO.read(outfile);
                   ColorModel cm = fromFile.getColorModel();
                   System.out.println(cm.getClass() + ", bits/pixel=" + cm.getPixelSize());
              catch(Exception e)
                   e.printStackTrace();
              return new File("map.png");
         public static GraphicsConfiguration getDefaultConfiguration()
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    return gd.getDefaultConfiguration();
         public static BufferedImage copyRescaled(BufferedImage tgt, BufferedImage src)
              Graphics2D g2 = tgt.createGraphics();
    int w=tgt.getWidth(), h=tgt.getHeight();
    hintForBestQuality(g2);
         g2.drawImage(src, 0, 0, w, h, null);
         g2.dispose();
    return tgt;
    public static Graphics2D hintForBestQuality(Graphics2D g2)
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
              RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2.setRenderingHint(RenderingHints.KEY_RENDERING,
              RenderingHints.VALUE_RENDER_QUALITY);
    return g2;
         public static BufferedImage rescale(BufferedImage src, int w, int h)
    int transparency = src.getColorModel().getTransparency();
    GraphicsConfiguration gc = getDefaultConfiguration();
    BufferedImage tgt = gc.createCompatibleImage(w, h, transparency);
    return copyRescaled(tgt, src);

    First, we need to be clear about what you're trying to do -- is it rescale an
    image or insure that the image is saved with a 8bit pixel depth? Or both? You are also
    using GraphicsConfiguration's createCompatibleImage, which is excellent if you are going
    to display the image immediately because it might be hardware accelerated
    or compatible with hardware format, but you mentioned mobile phone screens, so
    there is no advantage to using GraphicsConfiguration in that case, and if fact, it's
    probably changing your ColorModel when you're not looking.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.swing.*;
    public class Example {
        public static void main(String[] args) throws IOException {
            URL url = new URL("http://java.sun.com/developer/technicalArticles/GUI/JavaServerFaces/fig2.gif");
            BufferedImage image = ImageIO.read(url);
            System.out.println("image's colormodel = " + image.getColorModel().getClass());
            BufferedImage rescaled = scaleAndConvertColorModel(image, 0.75, null); //GIF => IndexColorModel
            System.out.println("rescaled's colormodel = " + image.getColorModel().getClass());
            File png = new File("junk.png");
            ImageIO.write(rescaled, "png", png);
            BufferedImage fromFile = ImageIO.read(png);
            System.out.println("fromFile's colormodel = " + image.getColorModel().getClass());
            JPanel cp = new JPanel(new GridLayout(0,1));
            addTo(cp, image, "original image");
            addTo(cp, rescaled, "rescaled image");
            addTo(cp, fromFile, "png file image");
            JFrame f = new JFrame("Example");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(cp);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            Will rescale and convert colormodel if necessary.
            ColorModel == null => don't convert. May return src if suitable.
        public static BufferedImage scaleAndConvertColorModel(BufferedImage src, double scale, ColorModel cm) {
            int w0 = src.getWidth();
            int h0 = src.getHeight();
            int w = (int) (w0 * scale);
            int h = (int) (h0 * scale);
            ColorModel cm0 = src.getColorModel();
            if (cm == null)
                cm = cm0;
            if (w==w0 && h==h0 && cm.equals(cm0))
                return src;
            BufferedImage tgt = createImage(w, h, cm);
            Graphics2D g = tgt.createGraphics();
            if (scale < 1) {
                Image temp = src.getScaledInstance(w, h, Image.SCALE_AREA_AVERAGING);
                g.drawImage(temp, null, null);
            } else {
                hintForBestQuality(g);
                g.drawRenderedImage(src, AffineTransform.getScaleInstance(scale, scale));
            g.dispose();
            return tgt;
        public static BufferedImage createImage(int w, int h, ColorModel cm) {
            if (w <= 0 || h <= 0)
                throw new IllegalArgumentException("...");
            boolean alphaPremultiplied = cm.isAlphaPremultiplied();
            WritableRaster raster = cm.createCompatibleWritableRaster(w, h);
            return new BufferedImage(cm, raster, alphaPremultiplied, null);
        public static Graphics2D hintForBestQuality(Graphics2D g) {
            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
            return g;
        static void addTo(Container c, BufferedImage image, String title) {
            JLabel label = new JLabel(new ImageIcon(image));
            label.setBorder(BorderFactory.createTitledBorder(title));
            c.add(label);
    }

  • How can I convert a bitmap image into an array in LabVIEW 6.0.2, then to a spreadsheet for further analysis without NI-IMAQ or Vision?

    I do not have NI-IMAQ or NI Vision.
    I acquired the image using a picolo board then just saved it as a bitmap file.

    You want to convert it to an array of what? Of numbers? Of LabVIEW colors?
    The "Read BMP File.vi" VI outputs a 1-D array of the pixels, but I suspect it is not exactly in the format that you need. I am NOT sure, but I think that each group of 3 elements of that 1-D array (which is inside the cluster "image data" that the VI outputs) represents the red, green and blue levels of a single pixel (but it may be hue, saturation and lum.). Also, since it is a 1-D array, you would have to divide it by the width (which is also included in the "image data" cluster) to get some sort of 2-D array of data.
    You can find the "Read BMP File.vi" VI in the functions palete> "Graphics & sound">"Graphics Formats".

  • How to convert JPEG - PNG images using java?

    Hi,
    Has anyone done this before?
    Can you provide me with a sample code or point me to the direction on how this can be done?
    Are there any existing Java technology that supports this?
    Most grateful. Thanks.

    It's should be easy using Java Advanced Imaging (JAI). Try this.
    import javax.media.jai.JAI;
    import javax.media.jai.RenderedOp;
    public class convert {
      static public void main(String[] args) {
        String inName = args[0];
        String outName = args[1];
        RenderedOp source = JAI.create("fileload", inName);
        JAI.create("filestore", source, outName, "PNG", null);
        System.exit(0);
    }

  • How can I do to convert a ".PNG" image file to a ".JPG" or ".BMP" one?

    My problem is to save an image (after processing and with overlay information!) to a standard file (JPG, BMP, ...); if I do it directly with the related VI's, the overlay information is lost; I can save the image in a ".PNG" file, which contains the complete information with overlay, but is not displayable on a LabView-less PC ! How can I do?
    Thank you for your prompt answers.
    Francois

    Hello Francois,
    As you noted, BMP and JPG file formats do not support overlay information. There are two approaches to your problem.
    1. Write to PNG file. PNG is not a LabVIEW specific file format. It cannot, however, be read by simple programs such as Windows Paint. Paint Shop Pro, Photoshop, among other more robust image viewing and editing programs can handle PNG files that LabVIEW generates.
    2. Flatten the overlay information into the main image before writing to BMP or JPG. I don't believe this functionality is built-in to LabVIEW, so this would require some programming, perhaps quite difficult. That is why LabVIEW supports PNG files.
    Jeff Boettcher
    National Instruments

  • Display an image from an array of bytes

    Hi, I'm trying to display an image from the raw pixel values. lets say i read a bmp file to an array, chuk the header off and want to display the pixel. How can I do this? I don't want any file formats, just want to display the pixels and creat the image. Is this possible?
    Many thanks,
    H

    Thanks for the reply. I had a look at MemoryImageSource and other classes that relates to it. I wrote the example given, but it doesn't identify createImage(). I've implemented ImageProducer, but still complains. Have you any idea why? Thanks for your help.
    H

  • Can I convert an ePub document to pdf format and vice versa?  If so, how?

    I would like to publish my book in both pdf and ePub formats.  If I create the book in one of these formats, can I convert the finished product to the other?  If so, how do I do that?

    It doesn't work to convert between PDF and EPUB, or back. Start with the same InDesign file and export separately to PDF and to EPUB.

  • Convert Feet and Inch to cm (and vice versa)

    I need some help with conversion of height. The form was designed by the department and there is a field where one need to enter the height of the participant.
    The height can either be in cm or in Feet + Inches (not just inches). Once a value has been entered in cm, it converts it automatically to feet and inches. If the user enter the height in feet and inches, it converts it immediately into cm. Much like the kg to lbs conversion fields in the attached document. I have been able to convert the height in cm into Feet and inches e.g. 165 cm = 5'5". However I am not sure how to do the opposite.
    The problem is the way it has been designed as there is a box for Feet and another box for Inches. If the other measure was in Inches only, it would have been easier and that would be like the kg to lbs conversion.
    I have tried multiple way to try to the conversion, but none would do it exactely like the kg to lbs conversion.
    Here is the form:
    https://workspaces.acrobat.com/?d=j8kksFor3eVIg6M07CdkmA

    I tried the following code, but obviously does not work. The problem reside in the fact that I have to reunite 2 fields to get the height in cm and am not sure how to handle that.
    var v1 = (function () {
        var f_source = getField("Feet");
        var result;
        if (event.source && event.source === f_source) {
            result = f_source * 30.48  ;
            event.value = result == 0 ? "" : util.printf("%.0f", result);
    var v2 = (function () {
        var f_source = getField("Inches");
        var result;
        if (event.source && event.source === f_source) {
            result = +f_source  * 2.54 ;
            event.value = result == 0 ? "" : util.printf("%.0f", result);
    event.value = v1 + v2;

  • Converting from String to float and vice versa

    I'm interested in people's thoughts on where common logic to convert between various field types should be stored in an application to minimise code duplication and maintenance.
    I have an application which consists of an object and a jPanel which displays and maintains this object. The object contains a number of private float fields which are accessed by getters and setters. The jPanel contains one jTextField for each of the fields within the object.
    Currently I have numerous lines of code in the jPanel to convert between the values needed by the getters and setters in the object (i.e. float) and the String value used by the jTextFields. This code handles cases where the String value may be blank or null.
    I've thought that one alternative to having all this conversion/validation code in the jPanel is to create a second set of getters and setters for each field which accept and return String values.
    What do people think about this? Is it advisable for only have one getter and setter for a variable? Should I put the conversion/validation logic for each field into a seperate common routine?
    Thanks,
    James.

    Hi James,
    You should go with whatever works best for you. By creating multiple getters and setter you save yourself from repeating the same code throughout your program.

Maybe you are looking for

  • Types of internal tables with regard to EFFICIENCY

    Will any one tell me syntax to define each type of internal table  (standard, sorted , hashed , database) . how to compare their efficincy ( access time which is more effficent) is there any documantation or programme of such type exist then please t

  • How do i upgrade to the later version

    How do i upgrade

  • Reduce File Size and Optimise PDF both increase file size

    Hi All I have exported a pdf (our college mag) at smallest file size from Indesign CS4 for online use. The problem is the resultant file size is a little under 19Mb. Using both or either Reduce File Size or Optimise functions simply result in an incr

  • XmlParse and XmlValidate

    I am getting an error thrown at me and I am not for sure why. I am using a cfc to send back XML code for the information required in a query. I have a dtd file that has been given to me by the company that is wanting this portal set up for them (chec

  • Flash site won't open on safari

    My site works on every browser except Safari for 2 days now. Before it worked perfectly. I tried many different computers and systematically it doesn't open any more. The page charges and stays white. On Explorer, Firefox and others it works normally