Advertisement
Luninariel

289 - Buffered Image Renderer

Apr 8th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. //
  2. //  BufferedImageRenderer.java
  3. //  SwingEasel
  4. //
  5. //  Created by Philip Rhodes on 9/2/05.
  6. //  Copyright 2005 Philip J Rhodes. All rights reserved.
  7. //
  8.  
  9.  
  10. import java.awt.*;
  11. import java.awt.image.*;
  12.  
  13.  
  14. /** This abstract class provides a BufferedImage for double buffering. Although
  15.  *  Swing provides double buffering by default, using a BufferedImage allows
  16.  *  us to access the array of bytes representing the image, speeding performance.
  17.  */
  18. public abstract class BufferedImageRenderer extends ImageRenderer{
  19.  
  20.    /** Create a VolatileImageRenderer to render the shapes in the World w.*/
  21.    BufferedImageRenderer(World w, int width, int height, boolean showFPS){
  22.      
  23.       super(w, width, height, showFPS);
  24.    }
  25.    
  26.    /** Creates the Buffered image and associated Graphics object. The image
  27.     *  takes its dimensions from the size of the JPanel. (Remember that this
  28.     *  class is a child of JPanel.)
  29.     */
  30.    public void init(){
  31.  
  32. //      do {
  33.      
  34.          this.backingImage = new BufferedImage(this.imageWidth, this.imageHeight, BufferedImage.TYPE_BYTE_INDEXED );
  35.          
  36. //      } while(this.backingImage == null);
  37.    
  38.       this.imageGraphics = this.backingImage.getGraphics();
  39.    }
  40.    
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement