LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-24-2004, 11:31 PM   #1
poeta_boy
Member
 
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Rep: Reputation: 31
Images on Java


Hello:

I wanna use an image on java and get it's histogram. The thing is that I have a class called ImageHandler:

Code:
public class ImageHandler
{
								public int[] pixels;						private int iw, ih;						private Image img;						private PixelGrabber ptr;					private ColorModel modelo;					
         public ImageHandler(Image img)
	{
		this.img = img;
		iw = 10;//img.getWidth(null);
		ih = 10;//img.getHeight(null);
		pixels = new int[iw*ih];
		ptr = new PixelGrabber(img, 0, 0, iw, ih, pixels, 0, iw);
		try{
		      ptr.grabPixels();
		}
		catch(Exception e){}
		modelo = ptr.getColorModel();
 		pixels = (int[])ptr.getPixels();
	}// constructor


}// class
Then I take the image in an Applet as follows

Code:
 
public class Imagenes extends JApplet
{
       ImageHandler imgHandler;
       Image image;						
       Label l;       
   
       public void init()
       {
                image = getImage(getDocumentBase(), "1.gif"); 
	imgHandler = new ImageHandler(image, 16);
                l.setText("The content of pixel 1 is:" + imgHandler.pixels[0])
       }
			
}//class
The Label l only shows negative numbers as -1323, -1, and 0's. any idea of why?

also you see I've commented the lines on iw and ih at Handler class because they will only generate an array of size 0............. but I did ask for the size right?

Thanks a lot!!!
 
Old 02-25-2004, 01:58 AM   #2
retep
Member
 
Registered: Sep 2003
Distribution: RedHat/Debian
Posts: 50

Rep: Reputation: 15
The pixel values will have their high bit set. Hence they are negative. I don't know why you're trying to ouput the pixels as a number. Perhaps you a binary output of the value would help you see how the pixels are set?
 
Old 02-25-2004, 10:51 AM   #3
poeta_boy
Member
 
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Original Poster
Rep: Reputation: 31
the pixel[] array will only give me the results as a "pixel object?" I mean, I can get it's ColorModel, then use each one of the array, let's say, to get the blue level:

for(int i = 0; i < pixels.length; i++)
modelo.getBlue(pixels[i]);

is that correct?
 
Old 03-03-2004, 12:29 AM   #4
poeta_boy
Member
 
Registered: Oct 2003
Location: Mexico
Distribution: Ubuntu
Posts: 223

Original Poster
Rep: Reputation: 31
please help!!!!!! :(

I try to do the getBlue(int pixel) thing but it only returns Zero's.......

why????

In the Java documentation I have two getBlue() methods from ColorModel, the one I use says it's abstrac and "premultiplied" I dunno what that is

please help me!


 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java plugin installed correctly for Firefox but not able to view any java applet tvn Linux - Software 10 04-15-2010 02:13 AM
Java Programming: Java Runtime Environment not found when trying to compile murbz Linux - Software 2 03-26-2009 03:04 AM
Convert cd images to dvd images rcsuk Debian 2 07-11-2005 10:34 AM
Transmit images between 2 Java applications Elec490 Linux - General 1 04-16-2005 09:10 AM
best way of handling images in Java secprovider Programming 1 09-22-2003 04:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration