[fixed] #####libgdx.so issue on Android.
static int gdx2d_blend = GDX2D_BLEND_NONE;\r
static int gdx2d_scale = GDX2D_SCALE_NEAREST;\r
\r
-gdx2d_pixmap* gdx2d_load(const char *buffer, int len, int req_format) {\r
+gdx2d_pixmap* gdx2d_load(const unsigned char *buffer, int len, int req_format) {\r
int width, height, format;\r
- const char* pixels = stbi_load_from_memory(buffer, len, &width, &height, &format, req_format);\r
+ const unsigned char* pixels = stbi_load_from_memory(buffer, len, &width, &height, &format, req_format);\r
if(pixels == NULL)\r
return NULL;\r
\r
pixmap->width = width;\r
pixmap->height = height;\r
pixmap->format = format;\r
- pixmap->pixels = (char*)malloc(width * height * format);\r
+ pixmap->pixels = (unsigned char*)malloc(width * height * format);\r
return pixmap;\r
}\r
void gdx2d_free(const gdx2d_pixmap* pixmap) {\r
gdx2d_scale = scale;\r
}\r
\r
-void gdx2d_clear(const gdx2d_pixmap* pixmap, int col) {\r
-\r
+void gdx2d_clear(const gdx2d_pixmap* pixmap, uint32_t col) {\r
+ \r
}\r
\r
-void gdx2d_set_pixel(const gdx2d_pixmap* pixmap, int x, int y, int col) {\r
+void gdx2d_set_pixel(const gdx2d_pixmap* pixmap, int x, int y, uint32_t col) {\r
\r
}\r
\r
-void gdx2d_draw_line(const gdx2d_pixmap* pixmap, int x, int y, int x2, int y2, int col) {\r
+void gdx2d_draw_line(const gdx2d_pixmap* pixmap, int x, int y, int x2, int y2, uint32_t col) {\r
\r
}\r
\r
-void gdx2d_draw_rect(const gdx2d_pixmap* pixmap, int x, int y, int width, int height, int col) {\r
+void gdx2d_draw_rect(const gdx2d_pixmap* pixmap, int x, int y, int width, int height, uint32_t col) {\r
\r
}\r
\r
-void gdx2d_draw_circle(const gdx2d_pixmap* pixmap, int x, int y, int radius, int col) {\r
+void gdx2d_draw_circle(const gdx2d_pixmap* pixmap, int x, int y, int radius, uint32_t col) {\r
\r
}\r
\r
-void gdx2d_fill_rect(const gdx2d_pixmap* pixmap, int x, int y, int width, int height, int col) {\r
+void gdx2d_fill_rect(const gdx2d_pixmap* pixmap, int x, int y, int width, int height, uint32_t col) {\r
\r
}\r
\r
-void gdx2d_fill_circle(const gdx2d_pixmap* pixmap, int x, int y, int radius, int col) {\r
+void gdx2d_fill_circle(const gdx2d_pixmap* pixmap, int x, int y, int radius, uint32_t col) {\r
\r
}\r
\r
#ifndef __GDX2D__\r
#define __GDX2D__\r
\r
+#include <stdint.h>\r
+\r
#ifdef __cplusplus\r
extern "C" {\r
#endif\r
int width;\r
int height;\r
int format;\r
- const char* pixels;\r
+ const unsigned char* pixels;\r
} gdx2d_pixmap;\r
\r
-extern gdx2d_pixmap* gdx2d_load (const char *buffer, int len, int req_format);\r
+extern gdx2d_pixmap* gdx2d_load (const unsigned char *buffer, int len, int req_format);\r
extern gdx2d_pixmap* gdx2d_new (int width, int height, int format);\r
extern void gdx2d_free (const gdx2d_pixmap* pixmap);\r
\r
extern void gdx2d_set_blend (int blend);\r
extern void gdx2d_set_scale (int scale);\r
\r
-extern void gdx2d_clear (const gdx2d_pixmap* pixmap, int col);\r
-extern void gdx2d_set_pixel (const gdx2d_pixmap* pixmap, int x, int y, int col);\r
-extern void gdx2d_draw_line (const gdx2d_pixmap* pixmap, int x, int y, int x2, int y2, int col);\r
-extern void gdx2d_draw_rect (const gdx2d_pixmap* pixmap, int x, int y, int width, int height, int col);\r
-extern void gdx2d_draw_circle (const gdx2d_pixmap* pixmap, int x, int y, int radius, int col);\r
-extern void gdx2d_fill_rect (const gdx2d_pixmap* pixmap, int x, int y, int width, int height, int col);\r
-extern void gdx2d_fill_circle (const gdx2d_pixmap* pixmap, int x, int y, int radius, int col);\r
+extern void gdx2d_clear (const gdx2d_pixmap* pixmap, uint32_t col);\r
+extern void gdx2d_set_pixel (const gdx2d_pixmap* pixmap, int x, int y, uint32_t col);\r
+extern void gdx2d_draw_line (const gdx2d_pixmap* pixmap, int x, int y, int x2, int y2, uint32_t col);\r
+extern void gdx2d_draw_rect (const gdx2d_pixmap* pixmap, int x, int y, int width, int height, uint32_t col);\r
+extern void gdx2d_draw_circle (const gdx2d_pixmap* pixmap, int x, int y, int radius, uint32_t col);\r
+extern void gdx2d_fill_rect (const gdx2d_pixmap* pixmap, int x, int y, int width, int height, uint32_t col);\r
+extern void gdx2d_fill_circle (const gdx2d_pixmap* pixmap, int x, int y, int radius, uint32_t col);\r
extern void gdx2d_draw_pixmap (const gdx2d_pixmap* src_pixmap,\r
const gdx2d_pixmap* dst_pixmap,\r
int src_x, int src_y, int src_width, int src_height,\r
/** the current version of libgdx in the major.minor format **/\r
public static String VERSION = "0.81";\r
\r
- public static void loadLibrary () {\r
- if (GdxNativesLoader.loadLibraries()) return;\r
-\r
+ public static void loadLibrary () { \r
String os = System.getProperty("os.name");\r
String arch = System.getProperty("os.arch");\r
+ String vm = System.getProperty("java.vm.name");\r
+ \r
+ if(!(vm != null && vm.contains("Dalvik")))\r
+ if (GdxNativesLoader.loadLibraries()) return;\r
\r
if (!arch.equals("amd64") || os.contains("Mac")) {\r
System.loadLibrary("gdx");\r
import java.io.ByteArrayOutputStream;\r
import java.io.IOException;\r
import java.io.InputStream;\r
+import java.nio.Buffer;\r
import java.nio.ByteBuffer;\r
\r
/**\r
*\r
*/\r
public class Gdx2DPixmap {\r
- static final int GDX2D_FORMAT_ALPHA = 1;\r
- static final int GDX2D_FORMAT_ALPHA_LUMINANCE = 2;\r
- static final int GDX2D_FORMAT_RGB = 3;\r
- static final int GDX2D_FORMAT_RGBA = 4;\r
+ public static final int GDX2D_FORMAT_ALPHA = 1;\r
+ public static final int GDX2D_FORMAT_ALPHA_LUMINANCE = 2;\r
+ public static final int GDX2D_FORMAT_RGB = 3;\r
+ public static final int GDX2D_FORMAT_RGBA = 4;\r
\r
final long basePtr;\r
final int width;\r
final ByteBuffer pixelPtr;\r
static final long[] nativeData = new long[4];\r
\r
- private Gdx2DPixmap(InputStream in, int requestedFormat) throws IOException {\r
+ public Gdx2DPixmap(InputStream in, int requestedFormat) throws IOException {\r
ByteArrayOutputStream bytes = new ByteArrayOutputStream();\r
byte[] buffer = new byte[1024];\r
int readBytes = 0;\r
format = (int)nativeData[3]; \r
}\r
\r
- private Gdx2DPixmap(int width, int height, int format) throws IllegalArgumentException {\r
+ public Gdx2DPixmap(int width, int height, int format) throws IllegalArgumentException {\r
pixelPtr = newPixmap(nativeData, width, height, format);\r
if(pixelPtr == null)\r
throw new IllegalArgumentException("couldn't load pixmap");\r
} catch(IllegalArgumentException e) {\r
return null;\r
}\r
- }\r
+ } \r
\r
private static native ByteBuffer load(long[] nativeData, byte[] buffer, int len, int requestedFormat);\r
private static native ByteBuffer newPixmap(long[] nativeData, int width, int height, int format);\r
\r
public static native void setBlend(int blend);\r
public static native void setScale(int scale);\r
+\r
+ public ByteBuffer getPixels () {\r
+ return pixelPtr;\r
+ }\r
+\r
+ public int getHeight () {\r
+ return height;\r
+ }\r
+ \r
+ public int getWidth () {\r
+ return width;\r
+ }\r
+ \r
+ public int getFormat() {\r
+ return format;\r
+ }\r
}\r