Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. import java.util.*;
  2. import java.awt.*;
  3. import java.awt.image.*;
  4.  
  5. public final class RSImageProducer {
  6.  
  7. public RSImageProducer(int anInt316, int anInt317, Component component) {
  8. this.width = anInt316;
  9. this.height = anInt317;
  10. this.component = component;
  11. int count = anInt316 * anInt317;
  12. anIntArray315 = new int[count];
  13. image = new BufferedImage(COLOR_MODEL, Raster.createWritableRaster(COLOR_MODEL.createCompatibleSampleModel(anInt316, anInt317), new DataBufferInt(anIntArray315, count), null), false, new Hashtable<Object, Object>());
  14. initDrawingArea();
  15. }
  16.  
  17. public void drawGraphics(int y, Graphics gfx, int x) {
  18. draw(gfx, x, y);
  19. }
  20.  
  21. public void draw(Graphics gfx, int x, int y) {
  22. gfx.drawImage(image, x, y, component);
  23. }
  24.  
  25. public void draw(Graphics gfx, int x, int y, int clipX, int clipY, int clipWidth, int clipHeight) {
  26. Shape tmp = gfx.getClip();
  27. try {
  28. clip.x = clipX;
  29. clip.y = clipY;
  30. clip.width = clipWidth;
  31. clip.height = clipHeight;
  32. gfx.setClip(clip);
  33. gfx.drawImage(image, x, y, component);
  34. } finally {
  35. gfx.setClip(tmp);
  36. }
  37. }
  38.  
  39. public void initDrawingArea() {
  40. DrawingArea.initDrawingArea(height, width, anIntArray315);
  41. }
  42.  
  43. public final int[] anIntArray315;
  44. public final int width;
  45. public final int height;
  46. public final BufferedImage image;
  47. public final Component component;
  48. private final Rectangle clip = new Rectangle();
  49. private static final ColorModel COLOR_MODEL = new DirectColorModel(32, 0xff0000, 0xff00, 0xff);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement