By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,554 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,554 IT Pros & Developers. It's quick & easy.

Generating images from data

P: n/a
Salve.

I'm somewhat new to Java, but I learn quickly. However, one thing that
I'm trying to do is stumping me badly.

I[0] have a network application, originally written in C, that transmits
images in a fairly simple but nonstandard format over a socket connection.
I've gotten as far as recieving and decompressing[1] the image data, but
I'm somewhat stumped as to how to get it onto the screen. The Swing and
AWT documentation in the API docs haven't helped too much; they do a great
job of listing methods and a poor job of outlining how those methods
interact with each other.

Options that have sprung out at me:

- implement ImageProducer. It looks like I can get ColorModel to do a
certain amount of the heavy lifting as far as converting the decompressed
image data into pixels goes, and there seems to be a way to get a Raster,
and thence an Image, out of it that way. Only problem is, I don't see how.

- Create a method that accepts a Graphics object and unRLEs the image data
into lines on the image. I *think* this might result in having to redo
the RLE decompression if the image is ever redrawn, which, if true, would
be non-optimal.

Any thoughts?

Owen
[0] My employer, actually.
[1] Simple RLE algorithm on each raster line.

--
Some say the Wired doesn't have political borders like the real world,
but there are far too many nonsense-spouting anarchists or idiots who
think that pranks are a revolution.

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Owen,

Probably the simplest way to do this would be to use a BufferedImage.
That way, you can just set the pixels yourself. Implementing an
ImageProducer might be more elegant, but would take a little more work.

--Nathan Davis

Owen Jacobson wrote:
Salve.

I'm somewhat new to Java, but I learn quickly. However, one thing that
I'm trying to do is stumping me badly.

I[0] have a network application, originally written in C, that transmits
images in a fairly simple but nonstandard format over a socket connection.
I've gotten as far as recieving and decompressing[1] the image data, but
I'm somewhat stumped as to how to get it onto the screen. The Swing and
AWT documentation in the API docs haven't helped too much; they do a great
job of listing methods and a poor job of outlining how those methods
interact with each other.

Options that have sprung out at me:

- implement ImageProducer. It looks like I can get ColorModel to do a
certain amount of the heavy lifting as far as converting the decompressed
image data into pixels goes, and there seems to be a way to get a Raster,
and thence an Image, out of it that way. Only problem is, I don't see how.

- Create a method that accepts a Graphics object and unRLEs the image data
into lines on the image. I *think* this might result in having to redo
the RLE decompression if the image is ever redrawn, which, if true, would
be non-optimal.

Any thoughts?

Owen
[0] My employer, actually.
[1] Simple RLE algorithm on each raster line.


Jul 17 '05 #2

P: n/a
i was under the impression that rle was a standard bitmap implementation
that should be ideal for the Java2D api to utilize. if not, then you'll
have to invest sometime investigating how Java2D works. a trip down to
your local book store is strongly advised. there are examples similiar
to what you are doing out there and java will be able to handle it for you.

- perry

Owen Jacobson wrote:
Salve.

I'm somewhat new to Java, but I learn quickly. However, one thing that
I'm trying to do is stumping me badly.

I[0] have a network application, originally written in C, that transmits
images in a fairly simple but nonstandard format over a socket connection.
I've gotten as far as recieving and decompressing[1] the image data, but
I'm somewhat stumped as to how to get it onto the screen. The Swing and
AWT documentation in the API docs haven't helped too much; they do a great
job of listing methods and a poor job of outlining how those methods
interact with each other.

Options that have sprung out at me:

- implement ImageProducer. It looks like I can get ColorModel to do a
certain amount of the heavy lifting as far as converting the decompressed
image data into pixels goes, and there seems to be a way to get a Raster,
and thence an Image, out of it that way. Only problem is, I don't see how.

- Create a method that accepts a Graphics object and unRLEs the image data
into lines on the image. I *think* this might result in having to redo
the RLE decompression if the image is ever redrawn, which, if true, would
be non-optimal.

Any thoughts?

Owen
[0] My employer, actually.
[1] Simple RLE algorithm on each raster line.


Jul 17 '05 #3

P: n/a
another approach would be to utilize the C code you already have that
receives and decompresses. under java you would access your C code using
JNI. there, you write a function that passes a decompressed bitmap back
to whatever needs it.

this can be and should be done in an elegant manner otherwise you'll end
up with code that you won't want to use. check out "Essential JNI"

- perry

Owen Jacobson wrote:
Salve.

I'm somewhat new to Java, but I learn quickly. However, one thing that
I'm trying to do is stumping me badly.

I[0] have a network application, originally written in C, that transmits
images in a fairly simple but nonstandard format over a socket connection.
I've gotten as far as recieving and decompressing[1] the image data, but
I'm somewhat stumped as to how to get it onto the screen. The Swing and
AWT documentation in the API docs haven't helped too much; they do a great
job of listing methods and a poor job of outlining how those methods
interact with each other.

Options that have sprung out at me:

- implement ImageProducer. It looks like I can get ColorModel to do a
certain amount of the heavy lifting as far as converting the decompressed
image data into pixels goes, and there seems to be a way to get a Raster,
and thence an Image, out of it that way. Only problem is, I don't see how.

- Create a method that accepts a Graphics object and unRLEs the image data
into lines on the image. I *think* this might result in having to redo
the RLE decompression if the image is ever redrawn, which, if true, would
be non-optimal.

Any thoughts?

Owen
[0] My employer, actually.
[1] Simple RLE algorithm on each raster line.


Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.