Hello, i'm looking for someone who is willing to help me with "Off Screen Rendering". I have created a sprite class, a image class, a own graphics class etc. but somehow it's not working properly. Because that would be too much to share everything here as code i would like to have a contact to someone who is interested in this topic. Mybe we can exchange a couple of ideas...
For example i'm using low level operations to manipulate the graphics. Here's a short part of my image class that you get some idea:
For example i'm using low level operations to manipulate the graphics. Here's a short part of my image class that you get some idea:
B4X:
Sub Class_Globals
Dim c_w As Int
Dim c_h As Int
Dim c_depth As Int
Dim c_pixels() As Int
Dim c_pixels_8() As Byte
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
End Sub
Public Sub setimage24(pixels() As Int, w As Int, h As Int)
Log("-> image::setimage24 (" & w & " x " & h & ")")
c_w = w
c_h = h
c_depth = 24
c_pixels = pixels
c_pixels_8 = Null
End Sub
Public Sub setimage8(pixels_8() As Byte, w As Int, h As Int)
Log("-> image::setimage8 (" & w & " x " & h & ")")
c_w = w
c_h = h
c_depth = 8
c_pixels = Null
c_pixels_8 = pixels_8
Log(" Anzahl: " & c_pixels_8.Length )
Log(" Test1: " & c_pixels_8(1) )
End Sub
Public Sub image24( jimg As Bitmap, force_depth As Int ) ' OK!
Dim I As Int
Dim x As Int
Dim y As Int
Dim s As Int
Dim r As Byte
c_w = jimg.Width
c_h = jimg.Height
c_depth = force_depth
Dim c_pixels(c_w * c_h) As Int
' Workaround for the java function pixelgrabber
Log("=== Pixelgrabber (" & c_w & "x" & c_h & ") " & force_depth & "bpp ===")
s = 0
For y = 0 To c_h-1
For x = 0 To c_w-1
c_pixels(s) = jimg.GetPixel(x,y)
s = s +1
Next
Next
If force_depth = 8 Then
Log("Switching into 8 bit color depth image size: " & c_w & "x" & c_h)
Dim c_pixels_8(c_w * c_h) As Byte
I = 0
For y = 0 To c_h-1
For x = 0 To c_w-1
r = Bit.And(c_pixels(I),0x000000FF)
If c_pixels(I) <> 0 Then
'Log("c_pixel("&I&") = " & c_pixels(I))
End If
c_pixels_8(I) = r ' Set Pixel
If c_pixels_8(I) <> 0 Then
'Log("Testing..")
End If
I = I + 1 ' Next!
Next
Next
c_pixels = Null ' Delete 24Bit Pixel Array because we have now 8 Bit
End If
End Sub
Public Sub imagexx(jimg As Bitmap) ' Wrapper for use without specific depth
image24(jimg,24)
End Sub