Image Displayer

  • Thread starter Chase Preuninger
  • Start date
C

Chase Preuninger

I want to figure out how to read a JPG file by just using the read
method in the InputStream class then I want to create a GUI component
that can display it.

1) How are the bytes formatted in a JPG file?
2) What is the best way to color individual pixels in a JComponent.

Please don't tell me to just use ImageIO and to draw it using a
Graphics object because I know how to do that.
 
M

mekane

Chase said:
I want to figure out how to read a JPG file by just using the read
method in the InputStream class then I want to create a GUI component
that can display it.

1) How are the bytes formatted in a JPG file?

Have you Googled for the JPEG spec?

2) What is the best way to color individual pixels in a JComponent.

Please don't tell me to just use ImageIO and to draw it using a
Graphics object because I know how to do that.


If I were you I would use the ImagIO packa-- oh, yeah, never mind. Good
luck with your project.
 
J

John B. Matthews

Chase Preuninger said:
I want to figure out how to read a JPG file by just using the read
method in the InputStream class then I want to create a GUI component
that can display it.

1) How are the bytes formatted in a JPG file?
2) What is the best way to color individual pixels in a JComponent.

[elided]

Just to get started, use one of the ImageIO.read() methods to get your
image into a BufferedImage. Then call getRaster() and have fun with the
raster's numerous setXXX methods. Then override paintComponent() in
whatever Component you extend:

protected void paintComponent(Graphics g) {
g.drawImage(bufferedImage, 0, 0, this);
}

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top