Revision: 2972
http://sourceforge.net/p/swingme/code/2972
Author: yuranet
Date: 2025-12-13 13:56:43 +0000 (Sat, 13 Dec 2025)
Log Message:
-----------
better test order to actually get valid alpha
Modified Paths:
--------------
SwingMETest/src/net/yura/mobile/test/GraphicsTest.java
Modified: SwingMETest/src/net/yura/mobile/test/GraphicsTest.java
===================================================================
--- SwingMETest/src/net/yura/mobile/test/GraphicsTest.java 2025-12-13 13:50:49 UTC (rev 2971)
+++ SwingMETest/src/net/yura/mobile/test/GraphicsTest.java 2025-12-13 13:56:43 UTC (rev 2972)
@@ -103,9 +103,29 @@
g.setColor(0xFFFF0000); // red
g.drawLine(0, 0, 50, 50);
+ // test saving file to disk
+ try {
+ //OutputStream out=FileUtil.getWriteFileConnection("file:///root1/img.jpg").openOutputStream();
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ ImageUtil.saveImage(img,out);
+ out.close();
+
+ img = Image.createImage(out.toByteArray(), 0, out.size());
+ }
+ catch(Exception ex) {
+ ex.printStackTrace();
+ }
+
+
+ // testing Nokia DirectGraphics
+ //com.nokia.mid.ui.DirectGraphics g2 = com.nokia.mid.ui.DirectUtils.getDirectGraphics(g);
+ //g2.fillPolygon(new int[] { 25,35,45,25,5},0,new int[] { 25,5,25,45,35},0,5,0xAA115599);
+
+ // test getting and setting pixel data from int array
int[] rgb = new int[img.getWidth() * img.getHeight()];
img.getRGB(rgb, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight());
-
for (int a = 0; a < 15 * img.getWidth(); a++) {
int x = a % img.getWidth();
int y = a / img.getWidth();
@@ -120,33 +140,13 @@
else {
newColor = 0x000000FF | alpha;
}
-
+ // test also modifying some of the values
rgb[a + 17 * img.getWidth()] = newColor;
}
-
img = Image.createRGBImage(rgb, img.getWidth(), img.getHeight(), true);
- rgb = null;
- // test saving file to disk
- try {
- //OutputStream out=FileUtil.getWriteFileConnection("file:///root1/img.jpg").openOutputStream();
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ImageUtil.saveImage(img,out);
- out.close();
-
- img = Image.createImage(out.toByteArray(), 0, out.size());
- }
- catch(Exception ex) {
- ex.printStackTrace();
- }
-
-
- // testing Nokia DirectGraphics
- //com.nokia.mid.ui.DirectGraphics g2 = com.nokia.mid.ui.DirectUtils.getDirectGraphics(g);
- //g2.fillPolygon(new int[] { 25,35,45,25,5},0,new int[] { 25,5,25,45,35},0,5,0xAA115599);
-
Label drawRegionPanel = new Label(new Icon(img));
addToScrollPane(drawRegionPanel, null);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|