Drawing outside of the viewable area..

Hi I’m trying to draw something out of viewing area, but somehow things outside of Canvas bound will not be drawed. Is there anyway I can still draw those? I need to copy the image there and be able to move it around… Any ideas?

Ex:
Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
g.setColor(Color.BLACK);
g.fillRect(-800, -600, 800, 600);

— other drawings

g.copyArea(-800, -600, 800, 600, 800, 600);

I believe you should use an offscreen buffer… I’m not too proficient, but I think I understand your question and this is what I use, so this should work :confused:


       Graphics goff;
       BufferedImage ii;
 
        // Initiates the offscreen buffer, should only be done once
        if ((ii == null) || (goff == null))
        {
            ii = new BufferedImage( BufferSizeX,  BufferSizeY ,BufferedImage.TYPE_INT_RGB);      
            goff = ii.getGraphics();       
        }


       // This would be in your paint loop -------------------------

       // Draws whatever to the offscreen buffer
       goff.drawImage( whateverImage, X,  Y, null);

       // Draws your offscreen buffer to the screen / current graphics context
       g.drawImage(ii, X, Y, null);


Hum… Thanks for the tip but that’s not exactly what I want. Because all the stuff in the drawing would have different coordinations and I only want to display a perticular view. Also there are many objects so I don’t want to translate all their coordinates first before drawing it.

You cant draw to memory that doesnt exist.

Soudsn to me liek what yo uwan tto do is create a compatible image as an offscreen buffer that is the size of the drawing space you want. Draw everything to it, then BLT the visible recatngle to your final window. Not the fastest graphcs path but AIUI the only way to draw the way you want to.