Revision: 2493
http://sourceforge.net/p/swingme/code/2493
Author: yuranet
Date: 2021-07-01 01:08:28 +0000 (Thu, 01 Jul 2021)
Log Message:
-----------
9 patchs load, yay
Modified Paths:
--------------
iOSME/src/javax/microedition/lcdui/Graphics.java
iOSME/src/javax/microedition/lcdui/Image.java
Modified: iOSME/src/javax/microedition/lcdui/Graphics.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Graphics.java 2021-06-29 19:22:29 UTC (rev 2492)
+++ iOSME/src/javax/microedition/lcdui/Graphics.java 2021-07-01 01:08:28 UTC (rev 2493)
@@ -23,6 +23,7 @@
import javax.microedition.lcdui.game.Sprite;
import android.graphics.ColorMatrix;
import org.moe.natj.general.ptr.NFloatPtr;
+import org.moe.natj.general.ptr.VoidPtr;
import org.moe.natj.general.ptr.impl.PtrFactory;
import org.moe.natj.objc.ObjCRuntime;
@@ -521,6 +522,11 @@
scanlength = width;
}
+
+ VoidPtr data = CoreGraphics.CGBitmapContextGetData(context);
+
+ //data.getIntPtr().
+
//int a = paint.getAlpha();
//paint.setAlpha(0xFF); // do not use alpha when drawing images
//canvas.drawBitmap(rgbData, offset, scanlength, tx+x, ty+y, width, height, processAlpha, paint);
Modified: iOSME/src/javax/microedition/lcdui/Image.java
===================================================================
--- iOSME/src/javax/microedition/lcdui/Image.java 2021-06-29 19:22:29 UTC (rev 2492)
+++ iOSME/src/javax/microedition/lcdui/Image.java 2021-07-01 01:08:28 UTC (rev 2493)
@@ -8,6 +8,8 @@
import android.graphics.ColorMatrix;
import org.moe.natj.general.ptr.BytePtr;
import org.moe.natj.general.ptr.ConstIntPtr;
+import org.moe.natj.general.ptr.IntPtr;
+import org.moe.natj.general.ptr.VoidPtr;
import org.moe.natj.general.ptr.impl.PtrFactory;
import apple.corefoundation.opaque.CFDataRef;
import apple.coregraphics.opaque.CGContextRef;
@@ -171,6 +173,12 @@
}
*/
public static Image createImage(int width, int height) {
+
+
+
+ //CoreGraphics.CGBitmapContextCreate(data, width, height, 8, );
+
+
UIKit.UIGraphicsBeginImageContext(new CGSize(width, height));
CGContextRef context = UIKit.UIGraphicsGetCurrentContext();
@@ -220,7 +228,13 @@
uiImage = UIKit.UIGraphicsGetImageFromCurrentImageContext();
if (uiImage == null) {
- throw new IllegalStateException("failed to get image from context " + context);
+ CGImageRef cgImageRef = CoreGraphics.CGBitmapContextCreateImage(context);
+
+ if (cgImageRef == null) {
+ throw new IllegalStateException("failed to get image from context " + context);
+ }
+
+ uiImage = UIImage.imageWithCGImage(cgImageRef);
}
UIKit.UIGraphicsEndImageContext();
context = null;
@@ -244,11 +258,17 @@
}
public int getWidth() {
- return (int) getUIImage().size().width();
+ if (uiImage == null) {
+ return (int) CoreGraphics.CGBitmapContextGetWidth(context);
+ }
+ return (int) uiImage.size().width();
}
public int getHeight() {
- return (int) getUIImage().size().height();
+ if (uiImage == null) {
+ return (int) CoreGraphics.CGBitmapContextGetHeight(context);
+ }
+ return (int) uiImage.size().height();
}
public Graphics getGraphics() {
@@ -264,8 +284,8 @@
context = UIKit.UIGraphicsGetCurrentContext();
Graphics displayGraphics = new Graphics(context);
+ displayGraphics.drawImage(this, 0,0, 0);
displayGraphics.setColor(0xFF000000);
- displayGraphics.drawImage(this, 0,0, 0);
uiImage = null;
return displayGraphics;
@@ -272,21 +292,34 @@
}
public void getRGB(int[] rgb, int offset, int scanlength, int x, int y, int width, int height) {
+ // TODO this does not seem to work, gives random crap back
+ /*
UIImage part = getUIImage(x,y,width,height,Sprite.TRANS_NONE);
-
CGDataProviderRef cgDataProviderRef = CoreGraphics.CGImageGetDataProvider(part.CGImage());
CFDataRef pixelData = CoreGraphics.CGDataProviderCopyData(cgDataProviderRef);
-
//long length = CoreFoundation.CFDataGetLength(pixelData);
//System.out.println("length " + length + " " + (getWidth() * getHeight()));
-
ConstIntPtr ints = pixelData.getIntPtr();
for (int pos = 0; pos < height; pos++) {
ints.copyTo(pos * width, rgb, offset + (pos * scanlength), width);
}
+ // TODO release stuff
+ */
- // TODO release stuff
+ //int imgWidth = getWidth();
+ Graphics g = getGraphics();
+
+ CoreGraphics.CGBitmapContextGetBitsPerComponent(context); // 8
+ CoreGraphics.CGBitmapContextGetBitsPerPixel(context); // 32
+ int srcScanLenght = (int)CoreGraphics.CGBitmapContextGetBytesPerRow(context) / 4; // 832
+
+ VoidPtr ptr = CoreGraphics.CGBitmapContextGetData(g.getContext());
+ IntPtr intPtr = ptr.getIntPtr();
+ for (int c = 0; c < height; c++) {
+ intPtr.copyTo((y+c) * srcScanLenght + x, rgb, offset + c * scanlength, width);
+ }
+
}
public boolean isMutable() {
@@ -295,8 +328,12 @@
}
public void setRGB(int x, int y, int color) {
- //uiImage.setPixel(x, y, color);
- throw new UnsupportedOperationException();
+ // TODO not sure this works
+ int width = getWidth();
+ Graphics g = getGraphics();
+ VoidPtr ptr = CoreGraphics.CGBitmapContextGetData(g.getContext());
+ IntPtr intPtr = ptr.getIntPtr();
+ intPtr.setValue(y * width + x, color);
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|