Results 1 to 8 of 8
Thread: Questions on images
- 04-19-2012, 08:12 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 23
- Rep Power
- 0
Questions on images
I have two questions regarding images
1)Is the process of extracting the pixel values ( using getRGB then right shift and 0xff ) the same for all image formats(jpeg,png)?
2)I am writing this program to change the values of certain pixels of an image.Which would be a preferred image format?I need to alter the certain pixel values of an image and then redraw the image.
Thank You
- 04-19-2012, 09:07 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,716
- Rep Power
- 19
Re: Questions on images
Are you talking about getRGB(int,int) of BufferedImage? In that case the image doesn't have a format. it's just an image: a bunch of pixels whose colours can be accessed.
Where formats enter into the picture (sorry) is when the image is externalised in some way - say read from or saved to a file on your hard drive, or obtained from a stream across the network. In that case there needs to be a format (some way of translating between the values in the stream and the coloured pixels.) The ImageIO class takes care of decoding some formatted stream to produce the (formatless) image, or encoding the image into a stream of bytes with some given format.
I would imagine that formats are important if you want to ensure that when you save an image then read it again you get the same coloured pixels that you started with. For that you would use a format like PNG which is lossless.
- 04-19-2012, 11:46 AM #3
Member
- Join Date
- Mar 2012
- Posts
- 23
- Rep Power
- 0
Re: Questions on images
Thank You for replying
Just to confirm
This means if I perform the operations
int rgb=image.getRGB(20,20);
int r=(rgb>>16)&0xff;
int g=(rgb>>8)&0xff;
int b=rgb&0xff;
I will get the rgb value of a pixel of a PNG image.
Also for steganographic purposes I should use PNG image.
- 04-19-2012, 12:29 PM #4
Re: Questions on images
Also for steganographic purposes I should use PNG image.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 04-19-2012, 01:19 PM #5
Member
- Join Date
- Mar 2012
- Posts
- 23
- Rep Power
- 0
Re: Questions on images
I was actually getting a lot of errors because of the fact that jpeg is a lossy compression.
- 04-19-2012, 01:58 PM #6
Re: Questions on images
I meant, what happened when you tried writing the image in PNG format?
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 04-20-2012, 08:20 AM #7
Member
- Join Date
- Mar 2012
- Posts
- 23
- Rep Power
- 0
Re: Questions on images
I will try writing it and post back...
- 05-20-2012, 03:14 AM #8
Member
- Join Date
- Mar 2012
- Posts
- 23
- Rep Power
- 0
Similar Threads
-
3 questions
By silverglade in forum New To JavaReplies: 11Last Post: 05-09-2011, 03:17 PM -
Various questions
By benn22 in forum New To JavaReplies: 2Last Post: 02-11-2011, 02:56 AM -
how to mark on 2 images at a time,both images are on different JPanel
By smitharavi in forum AWT / SwingReplies: 0Last Post: 12-16-2010, 05:14 PM -
how to scroll 2 images at a time(synchronisation),both images are on different panels
By smitharavi in forum AWT / SwingReplies: 4Last Post: 12-16-2010, 04:32 PM -
questions for 1yr exp
By rahaman.athiq in forum Java ServletReplies: 2Last Post: 11-26-2008, 01:13 AM
Bookmarks