Composite Images

C

CDB

Hello, can someone tell me wht is wrong with the following code to
create a composite image:
When I do this, I just get a large yellow square...

protected void compositeImage()
{
if (displayImage == null)
createDisplayImage();

if (offScrImage == null)
offScrImage = new BufferedImage(width,height,imageType);

int dx1 = 0;
int dy1 = 0;
int dx2 = imageWidth;
int dy2 = imageHeight;
int sx1=0;
int sy1=0;
int sx2=imageWidth;
int sy2=imageHeight;

if (offScrGc == null)
offScrGc = offScrImage.createGraphics();
offScrGc.setColor(Color.yellow);
offScrGc.fillRect(0,0,width,height);
offScrGc.setClip(width,height);

for (int i=0; i<imageset.length; i++){
offScrGc.drawImage(imageset,dx1, dy1, dx2, dy2, sx1,sy1, sx2,
sy2,null);
}

dispGc.drawImage(offScrImage,0,0,this); // the invert

}

protected void createDisplayImage(){
displayImage = new BufferedImage(width,height,imageType);
setOffScrGc();
}


protected void setOffScrGc(){
if(displayImage!= null){
dispGc = displayImage.createGraphics();
dispGc.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
dispGc.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
dispGc.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);

dispGc.setColor(getBackgroundColor());
dispGc.fillRect(0,0, width, height);
dispGc.setColor(getForegroundColor());
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top