Hey everyone,
I'm working on a program based on steganography. For this, i need to access the individual pixels and perform my manipulations. FYI, I do not have the JAI library available with me and I have to make do with awt, imageIO and image. I'm having no issues in loading an image but when i thought I would test things and just save the same image without manipulation I was surprised. After copying the pixels from the image into an int array, I just created a new image with the same pixel array and image type. When I loaded the new image and compared both their pixels, the array was not the same! Can anyone tell me why this is happening and/or how I can get around this?
Here is some of my code: -
-
//In the class ImgStuff
-
public BufferedImage loadImg(String fileName){
-
BufferedImage bImg = null;
-
try {
-
-
bImg = ImageIO.read(new File(fileName));
-
return bImg;
-
} catch (Exception e) {
-
e.printStackTrace();
-
return null;
-
}
-
-
}
-
-
-
//In function 'main' of StegoTest.java
-
-
ImgStuff img = new ImgStuff();
-
BufferedImage b = img.loadImg("D:/c.jpg");
-
int pixels[] = new int[b.getWidth()*b.getHeight()];
-
b.getRGB(0, 0, b.getWidth(), b.getHeight(), pixels, 0, b.getWidth());
-
BufferedImage b2;
-
/* b2.setRGB(0, 0, b.getWidth(), b.getHeight(), pixels, 0, b.getWidth()); <-- doesn't work this way either */
-
File file = new File("D:/done2.jpg");
-
try{
-
ImageIO.write(b, "JPEG",file);
-
}catch(Exception e){
-
System.out.println(e);
-
}
-
b2 = img.loadImg("D:/done2.jpg");
-
int pixels2[] = new int[b2.getWidth()*b2.getHeight()];
-
b2.getRGB(0, 0, b2.getWidth(), b2.getHeight(), pixels2, 0, b2.getWidth());
-
/*compare the pixel arrays*/
-
for(int i=0;i<pixels2.length;i++){
-
if(pixels[i]!=pixels2[i]){
-
System.out.println("No");
-
break;
-
}
-
}
-
Could really use your help here. I've tried "jpg", "jpeg" and various uppercase combination for the 'format' argument.
Thanks in advance,
Nikhil
0 2013 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Clyde Ellul |
last post by:
Hi there.
I need to write a simple program that reads a GIF image from an input
stream, resizes it, then writes it back to an output stream in the
same format (GIF). (JPEG input/output is good...
|
by: Aaron Davies |
last post by:
I'm trying to write some classes for my collaborative whiteboard to
transmit images over the network, using the javax.imageio API, but I'm
running into an odd problem: my code words fine with PNGs,...
|
by: Mark McKay |
last post by:
I will be starting a contract with a film production company soon, and
will be writing code to process large images representing frames of
movies (unknown file format at this time). I'd also like...
|
by: Stephen Poley |
last post by:
People in these groups, and on web-pages, not infrequently suggest that
it is worthwhile cutting down on white-space and comments in HTML and
CSS in order to reduce loading times. I and others have...
|
by: IkBenHet |
last post by:
Hello,
I use this script to upload image files to a folder on a IIS6 server:
******************* START UPLOAD.ASPX FILE **********************
<%@ Page Language="VB" Debug="true" %>
|
by: Nathan Sokalski |
last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
|
by: ttamilvanan81 |
last post by:
Hai everyone,
I need to provide the slideshow for the images.
I have upload the images into database. Then i will retrive all the images from the database and provide the slideshow for those...
|
by: ashsa |
last post by:
Hi,
Am trying to extract an image from a URL as follows:
try
{
BufferedImage input = ImageIO.read(new URL("http://www.google.co.in/images/close_sm.gif"));
File outputFile = new...
|
by: mndprasad |
last post by:
hi all
i am doing a project in java where i need to convert 10 jpeg images into a single tiff image..conversion of single jpeg image to single tiff is happening but embedding all the 10 jpeg images...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |