javaarraysbitmapsurfacegame-maker

Java extension return a Bitmap(image) as a Byte Array as a String and I need to display the image in my Game. How?


so I have a java extension( java code: https://pastebin.com/cpwf5LzT ). It has 1 function and the function have 1 argument that is a String called fname. And it returns a String. The function should get the file from the path of fname and if it's an image file, get it as a Bitmap. then I change the Bitmap to a byte array( byte[] ) and then the byte array to String and returns it.

The Extension works fine, but my problem is that I don't know how to change the String variable the function returns to a byte array and the byte array to sprite or paste it on a surface.

So can anybody with some knowledge about that kind of stuff can help me with that? Thanks!

UPDATE #1:

So I managed to add the Output String into a buffer and draw it but this is how it turns out compared to the original image: image

Tho if I make a new sprite, draw the sprite to a surface and gets the bitmap of the surface to the buffer, it turns out fine...

This is the code I used: https://pastebin.com/KhPhVr5p (The load_image function is the function of the java extension) (The draw_buffer function is a function that uses this extension's functions and should draw the buffer)

Maybe it's because of the buffer_getpixel extension? What can I use to replace it?


Solution

  • There are at least a couple issues here,