conversion of raw image data into readable format

  • Follow


I have a block of raw image data and I am looking for methods to
create an empty bitmap file and dump those bytes of raw data into the
image data section of the bitmap file. I am famaliar with doing this
in C using some provided functions but how can it be done in Java?

Thanks
0
Reply steve 2/25/2009 8:47:44 PM

In article 
<945cf097-ce86-4c1f-8c89-4e7d4c518bb0@f4g2000vbf.googlegroups.com>,
 steve <Stephen.Schoenberger@gmail.com> wrote:

> I have a block of raw image data and I am looking for methods to
> create an empty bitmap file and dump those bytes of raw data into the
> image data section of the bitmap file. I am famaliar with doing this
> in C using some provided functions but how can it be done in Java?

You can write to the raster of a BufferedImage, e.g.:

<http://sites.google.com/site/drjohnbmatthews/raster>
<http://java.sun.com/javase/6/docs/api/java/awt/image/BufferedImage.html>
<http://java.sun.com/javase/6/docs/api/java/awt/Component.html#createImage(int,%20int)>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
0
Reply John 2/25/2009 9:20:01 PM


On Feb 25, 3:47=A0pm, steve <Stephen.Schoenber...@gmail.com> wrote:
> I have a block of raw image data and I am looking for methods to
> create an empty bitmap file and dump those bytes of raw data into the
> image data section of the bitmap file. I am famaliar with doing this
> in C using some provided functions but how can it be done in Java?

I'm not very expert with Java graphics, but it looks like you need
elements of the java.awt.image package,
<http://java.sun.com/javase/6/docs/api/java/awt/image/package-
frame.html>
such as Image and BufferedImage,
<http://java.sun.com/javase/6/docs/api/java/awt/Image.html>
<http://java.sun.com/javase/6/docs/api/java/awt/image/
BufferedImage.html>
Raster,
<http://java.sun.com/javase/6/docs/api/java/awt/image/Raster.html>
WritableRaster,
<http://java.sun.com/javase/6/docs/api/java/awt/image/
WritableRaster.html>
and DataBuffer
<http://java.sun.com/javase/6/docs/api/java/awt/image/DataBuffer.html>
and its descendants.

--
Lew

0
Reply Lew 2/25/2009 9:21:44 PM

On Feb 25, 4:20=A0pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> In article
> <945cf097-ce86-4c1f-8c89-4e7d4c518...@f4g2000vbf.googlegroups.com>,
>
> =A0steve <Stephen.Schoenber...@gmail.com> wrote:
> > I have a block of raw image data and I am looking for methods to
> > create an empty bitmap file and dump those bytes of raw data into the
> > image data section of the bitmap file. I am famaliar with doing this
> > in C using some provided functions but how can it be done in Java?
>
> You can write to the raster of a BufferedImage, e.g.:
>
> <http://sites.google.com/site/drjohnbmatthews/raster>
> <http://java.sun.com/javase/6/docs/api/java/awt/image/BufferedImage.html>
> <http://java.sun.com/javase/6/docs/api/java/awt/Component.html#createI...=
)>
>
> --
> John B. Matthews
> trashgod at gmail dot com
> <http://sites.google.com/site/drjohnbmatthews>

Some more information might help here. I know the image data is
quantized to eight bits (256 gray levels) contained in each byte. I
like the raster idea but will this work given the image data format I
have?
0
Reply steve 2/25/2009 9:32:36 PM

In article 
<9ed2488f-3c51-4eec-a04d-410b721cd6e6@q27g2000vbn.googlegroups.com>,
 steve <Stephen.Schoenberger@gmail.com> wrote:

> On Feb 25, 4:20 pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> > In article
> > <945cf097-ce86-4c1f-8c89-4e7d4c518...@f4g2000vbf.googlegroups.com>,
> >
> >  steve <Stephen.Schoenber...@gmail.com> wrote:
> > > I have a block of raw image data and I am looking for methods to
> > > create an empty bitmap file and dump those bytes of raw data into the
> > > image data section of the bitmap file. I am famaliar with doing this
> > > in C using some provided functions but how can it be done in Java?
> >
> > You can write to the raster of a BufferedImage, e.g.:
> >
> > <http://sites.google.com/site/drjohnbmatthews/raster>
[...] 
> Some more information might help here. I know the image data is
> quantized to eight bits (256 gray levels) contained in each byte. I
> like the raster idea but will this work given the image data format I
> have?

Yes, for raw data it's the easiest way to go. Given an array of int,

    int[] iArray = { 0, 0, 0, 255 };

for each pixel, set the R, G and B components to the same eight bit 
value; the alpha doesn't change:

    iArray[0] = v;
    iArray[1] = v;
    iArray[2] = v;
    raster.setPixel(col, row, iArray);

If you can read the original data into a BufferedImage, it should be 
possible to do something similar with ColorConvertOp:

<http://java.sun.com/javase/6/docs/api/java/awt/image/ColorConvertOp.html>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
0
Reply John 2/26/2009 2:28:03 AM

4 Replies
659 Views

(page loaded in 0.002 seconds)

Similiar Articles:













7/21/2012 12:04:28 AM


Reply: