• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating image file after manipulation in bits of image

 
Amit jain Mait
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am working on a project where i manipulated bits of image by taking first their pixel value in integer format then this value in bit format
.After manipulation, i reconstruct the integer from the bits....

now problem is i am unable to make the image from this integer values.....

Please help me out.....
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's been awhile since I've done this, but I think it involves java.awt.Toolkit to convert the byte array into an Image, and then ImageIO to write the image to a file. There used to be limitations on GIFs, because the GIF encoder was patented, even though the GIF decoder was free. I think that limitation has been lifted though.

Meanwhile, I'll move this over to the GUI forum for a better answer.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "make the image"? What kind of object or data structure are you working with?

If you have a BufferedImage you can use the getRGB and setRGB methods for operations on individual pixels. The ImageIO class can read image files into a BufferedImage, and can write BufferedImage to a file - no need to use Toolkit these days.

If preserving pixel values is important, avoid GIF and JPEG - use PNG.
 
Amit jain Mait
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code snippt


here is ImageAttribute class




i am not using setRGB to change pixel value.

my requirement is to change only last bit of bit representation of pixel then make image from that.

 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what happens when you run this code?
 
Amit jain Mait
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Lester Burnham

although code is running but it is not creating images with equal size as that of image to which i made changes..

 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By "size", do you mean width and height? I guess those should be the same, but it's impossible to say without seeing the code. The file size, of course, could well be different.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!