Libraryless. Click here for Pure Java version (5803L/32K).
srecord noeq VolatileImageMakerForComponent(Component component, int w, int h, Renderable renderable) { VolatileImage vImg; long contentsLostCounter; event fireContentsLost; // rendering to the image void renderOffscreen() { do { if (vImg.validate(component.getGraphicsConfiguration()) == VolatileImage.IMAGE_INCOMPATIBLE) // old vImg doesn't work with new GraphicsConfig; re-create it vImg = component.createVolatileImage(w, h); Graphics2D g = vImg.createGraphics(); renderable.renderOn(g, w, h); g.dispose(); } while (contentsLost()); } void paintOnScreen(Graphics2D gScreen) { do { if (vImg == null) vImg = component.createVolatileImage(w, h); int returnCode = vImg.validate(component.getGraphicsConfiguration()); if (returnCode == VolatileImage.IMAGE_RESTORED) { // Contents need to be restored renderOffscreen(); } else if (returnCode == VolatileImage.IMAGE_INCOMPATIBLE) { // old vImg doesn't work with new GraphicsConfig; re-create it vImg = component.createVolatileImage(w, h); renderOffscreen(); } gScreen.drawImage(vImg, 0, 0, component); } while (contentsLost()); } bool contentsLost() { if (!vImg.contentsLost()) false; ++contentsLostCounter; fireContentsLost(); true; } bool sizeIs(int w, int h) { ret this.w == w && this.h == h; } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033788 |
Snippet name: | VolatileImageMakerForComponent |
Eternal ID of this version: | #1033788/10 |
Text MD5: | 6e4113eda989bafadac3edc728f22802 |
Transpilation MD5: | 56d7d1568e8b2ea20b419166b0f16bcf |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-05 22:46:29 |
Source code size: | 1540 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 169 / 297 |
Version history: | 9 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) #1034400 - JVolatileImageSurface [seems to work] |