This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes setBrightness Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setBrightness" Watch "setBrightness" New topic
Author

setBrightness

conor murphy
Greenhorn

Joined: May 06, 2006
Posts: 15
hi

i have an image stored in an ImageIcon. i am trying to set the brightness using a slider. i have found a few tutorials that use the setBrightness function but this is used on an ImageDisplay object. is there anyway to get a setBrightness function on the ImageIcon or anyway to convert the ImageIcon into an ImageDisplay and then set the brightness and convert it back to an ImageIcon.

thanks
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
I've never heard of ImageDisplay -- it's not in the J2SE. What package is it in? Anyway, have you done the 2D API tutorial:

http://java.sun.com/docs/books/tutorial/2d/index.html

The section on filtering may give you ideas.


There is no emoticon for what I am feeling!
conor murphy
Greenhorn

Joined: May 06, 2006
Posts: 15
hi

i have a program called JAI tutor. it is a tutorial on how to use the JAI api and it uses ImageDisplay. i havent been able to find anything on it though.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by conor murphy:

i have a program called JAI tutor.


Oh, JAI. It's on my list of things to learn, but until now everything I've needed to do with images I've been able to do with J2SE (the 2D API).
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
It's on my list of things to learn

I think it's dead. It hasn't progressed significantly in years, and now being hosted at dev.java.net, I don't expect Sun to release anything beyond 1.1.x.


Ping & DNS - my free Android networking tools app
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by Ulf Dittmer:

I think it's dead.


As useful as the 2D API of the J2SE is, there are times you need to go beyond it, for example, when working with large images. Is there another Java library that's being promoted for advanced graphics?
conor murphy
Greenhorn

Joined: May 06, 2006
Posts: 15
ive got to use the JAI library for an assignment at uni. they told us we are not allowed to use anything else excpet the JAI library. i found a way to do it using lookups but i dont really understand how it works so i dont want to use it if i cant tell what it does

here is the code anyway. maybe someone has seen this code before and can explain what is happening

// Brightness processor
public void processBrightContrast(int ipParam, Image pImage){

Image mImage = pImage;
//Create parameter block
ParameterBlock mPB = new ParameterBlock();
//Add image source to parameter block
mPB.addSource(mImage );

byte lutData[];
lutData = new byte[256];
for(int j = 0; j < 256; j++)
lutData[j] = clampByte(j + ipParam);

LookupTableJAI mLookup = new LookupTableJAI(lutData);

mPB.add(mLookup );
RenderedOp mRenOp;

// Process the brightness/ darkness
mRenOp= JAI.create("lookup", mPB, null);
return mRenOp.getAsBufferedImage();
}


private final byte clampByte(int i)
{
if(i > 255)
return -1;
if(i < 0)
return 0;
else
return (byte)i;
}

thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
Is there another Java library that's being promoted for advanced graphics?


JOGL/OpenGL (also on dev.java.net) is progressing nicely, although it's more a replacement for Java3D -which is also dead- than JAI I think. I like ImageJ, since it's also a ready-to-use application, but it doesn't come close to JAI in terms of general functionality. It does have some amazing plugins contributed by other people, though.
 
GeeCON Prague 2014
 
subject: setBrightness