CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: offScreenImage

  1. #1
    Guest

    offScreenImage


    how can I draw in a offScreenImage and only then draw the offScreenImage in a pannel? And how can I obtain the offScreenImage?


  2. #2
    Join Date
    Apr 2000
    Location
    Canada
    Posts
    27

    Re: offScreenImage

    To draw onto an off screen image, you invoke the method "getGraphics()" on the image. Then you can paint over the image using the graphics object as you normally would in the paint method.

    Here's an example:

    off_screen_image.getGraphics().drawString("This is a string.", 25, 25);




    This draws the string "This is a string." onto the image at the coordinates 25, 25. You can also just store the graphics object by using off_screen_image.getGraphics() instead.

    If you want to draw the image in a panel, you must extend java.awt.Panel. Then in the paint method, you can draw the off screen image.

    To obtain the off screen image, use the java.awt.Component method "createImage(int, int)" to create an image of the specified width and height.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured