Re: byte[] to Image, HELP

From: Alex Molochnikov (NOBODY_at_NOSPAM.COM)
Date: 02/16/04


Date: Mon, 16 Feb 2004 22:53:44 GMT

Image img = Toolkit.getDefaultToolkit().createImage(buf);

"Cyril Mrazek" <cyril.mrazek@bluewin.ch> wrote in message
news:fkg230trbaqjho87eh8suapa8hgoep0n99@4ax.com...
> Hello,
>
> I have a byte array, I get it from a Blob, such that if I write it
> into a FileOutputStream, I get a file on the disk:
>
>
>
> ... some SQL
> Blob blob = rs.getBlob(1);
> int c = (int)blob.length();
> byte[] buf = blob.getBytes(1, c);
> FileOutputStream fos = new FileOutputStream("sample.jpg");
> fos.write(buf, 0, c);
> ...
>
>
>
> and it works fine. Now I would like to generate an Image, or a
> BufferedImage, from that buffer and I can't find a way to do it. Any
> hint ?
>
> Thanks
>
> Cyril Mrazek



Relevant Pages

  • Re: where is the error....???help me to find it!!!!
    ... stores it into an array of byte and put it in a blob ... | Sets the designated parameter to the given Java array of bytes. ...
    (comp.lang.java.programmer)
  • Re: how to get byte[] from an image
    ... A byte array or an int array? ... It's probably trivial to adapt it to return an int[] ... {@link BufferedImage}. ... internal DataBuffer banks isn't 1. ...
    (comp.lang.java.programmer)
  • Re: Structure padding
    ... >>newly malloced memory overwriting existing heap variables. ... >>Will this have alignment problems with gaps in the Blob struct? ... > The use of a zero-element array is not allowed in standard C. There's ...
    (comp.unix.programmer)
  • Re: Data representation in application
    ... > streamed to a BLOB field ... With an array of records you will need to write code for managing the array, ... from database (blob or otherwise). ... database anyway, but with no components to help you. ...
    (borland.public.delphi.language.objectpascal)
  • Re: Multidimensional arrays in Java.
    ... like `stud' and the thing it refers to. ... of an array; it is the name of a reference variable. ... In this snippet, `blob' is the name of a reference variable, ... between the reference variables `blob' and `glob' and the ...
    (comp.lang.java.programmer)