This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes Draw Image Off-Screen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Draw Image Off-Screen" Watch "Draw Image Off-Screen" New topic

Draw Image Off-Screen

Mocky Johnson

Joined: Aug 05, 2004
Posts: 8
Hi, I am doing a school project and i need to save two images as one image which have been drawn on top of each other. According to my teacher, he told us to first draw the image off-screen than firsly draw both images on an off-screen imagecreate an integer array in the site of width x height of that off-screen image, and use Image.getRGB() to fill it with all pixels values.Convert this int array to larger byte array and store it in the rms. I have problems starting off and drawing the image off-screen. Can someone pls help me. Thank you very much. Your help will be very much appriecated.

Thanks again
Punit Raizada
Ranch Hand

Joined: Mar 20, 2004
Posts: 156

iam sorry but i think i did not understand your question correctly. let me know if iam thinking in the wrong direction.
1) You have two images Image A and Image B
2) Your goal is to create an Image C
3) Image C will be Image A superimposed on Image B

Did i get your assignment correctly ? ... I really did not get the meaning of drawing the image offscreen.

I would investigate the Alfa (transparency) level of the Image objects if this is the case.

[ August 05, 2004: Message edited by: Punit Raizada ]

SCJP 1.4
Everything that can go wrong will go wrong -Murphy
Mocky Johnson

Joined: Aug 05, 2004
Posts: 8
yes sir, u got it correct. I have get image1 with is overlapped over image2 as one image. and the method my teacher suggested was to draw the two images on top of each other but off screen than put it inside an int array than put it into an byte array so that i can be save.

I have done the off-screen drawing of the images but i do not know how to put it into array and change it to huge bytes.

Please try to help me sir thank you very much your help will be very much appreciated.
Punit Raizada
Ranch Hand

Joined: Mar 20, 2004
Posts: 156
Hi Mocky,

I assume drawing Image off screen is geting the int array for the Image object from getRGB() method. Is this correct ?

so now you have 2 int arrays for 2 images A and B with each int in the format ARGB. I assume these are the 2 things you want to do
1) Create an int array with pixel values (in ARGB format) for a new image C that is the overlap of Images A and B.
2) Convert this int array and store it in the RMS.

The first step really depends on you. What kind of overlapping .. i mean what kind of an output image u expect after the overlap of images A and B. I think and iam not too sure .. you could OR the images. For reading up on Imaging functions check out

As for the second step ... iam not sure this is the best way but this is one way. Assume your int array is pixelData

the other way you can do it is with streams

The last line actually stores the byte data into the recordset. rs_Setting is a reference to a open Record Store.

I think you should be able to place the byte array in one record.

hope this helps.

Does anyone know of a maximum limit on the number of bytes of data that can be placed in one record of the recordstore ?
[ August 06, 2004: Message edited by: Punit Raizada ]
Mocky Johnson

Joined: Aug 05, 2004
Posts: 8
Thank you very much. Your help has been very well appreciated.
subject: Draw Image Off-Screen
Similar Threads
Background image
how to create an image through bufferedimage,image and other helper class using byte array
drawing on images.
color detection with mouse
how to remove unwanted pixels from image