I just filed a bug report for RGBSurface. When the sample code from Xojo is used, it runs fine when compiled 32 bit, but does not when compiled 64 bit;
[code]Dim surf As RGBSurface = somePicture.RGBSurface
Dim lastX As Integer = somePicture.Width - 1
Dim lastY As Integer = somePicture.Height - 1
For y As Integer = 0 To lastY
For x As Integer = 0 To lastX
If surf.Pixel(x,y) = &c000000 Then
surf.Pixel(x,y) = &cFFFFFF
End if
Next
Next
You can replace Surf by somepicture.graphics but I suspect there is something else with your picture.
[code] Dim lastX As Integer = somePicture.Width - 1
Dim lastY As Integer = somePicture.Height - 1
For y As Integer = 0 To lastY
For x As Integer = 0 To lastX
If val(str(somepicture.graphics.Pixel(x,y))) < &h202020 Then
somepicture.graphics.Pixel(x,y) = &c00FF00
End if
Next
Next
[quote=237541:@Michel Bujardet]It works just fine here.
You can replace Surf by somepicture.graphics but I suspect there is something else with your picture.
[code] Dim lastX As Integer = somePicture.Width - 1
Dim lastY As Integer = somePicture.Height - 1
For y As Integer = 0 To lastY
For x As Integer = 0 To lastX
If val(str(somepicture.graphics.Pixel(x,y))) < &h202020 Then
somepicture.graphics.Pixel(x,y) = &c00FF00
End if
Next
Next
@Michel Bujardet : It works fine only in 32 bit, not in 64 bit. The image is a plain vanilla Jpeg;
The code in the canvas paint event;
[code] Dim surf As RGBSurface = AdeleMini.RGBSurface
Dim lastX As Int16 = AdeleMini.Width - 1
Dim lastY As Int16 = AdeleMini.Height - 1
For y As Int16 = 0 To lastY
For x As int16 = 0 To lastX
If surf.Pixel(x,y) = &c000000 Then
surf.Pixel(x,y) = &cFFFFFF
End if
Next
Next
Following Michel’s comment on using graphics instead of RGBsurface; that does work as expected, so thanks for that suggestion Michel.
So is this a 64 bit bug in RGBsurface or am I just missing something on how RGBsurface works?
I also tried creating a local copy of the image and working on that.
Same thing.
Works fine substituting graphics for rgbsurface
[code] dim p as new picture (Adelemini.width,Adelemini.height,32)
p.Graphics.drawpicture Adelemini,0,0
Dim surf As RGBSurface = p.RGBSurface
Dim lastX As Int16 = AdeleMini.Width - 1
Dim lastY As Int16 = AdeleMini.Height - 1
For y As Int16 = 0 To lastY
For x As int16 = 0 To lastX
If surf.Pixel(x,y) = &c000000 Then
surf.Pixel(x,y) = &cFFFFFF
End if
Next
Next
@Michel Bujardet :[quote]Both are fine, but RGBSurface is faster.[/quote]
That’s exactly why I would like it to work in 64 bit with RGBsurface instead of graphics, which it does not on 2015R3 or 2015R4
I investigated further. The bug is not in getting the pixel, it is in setting it.
This works just fine in a 64 bit build.
[code]dim p as new picture (Adelemini.width,Adelemini.height,32)
p.Graphics.drawpicture Adelemini,0,0
Dim surf As RGBSurface = p.RGBSurface
Dim lastX As Int16 = AdeleMini.Width - 1
Dim lastY As Int16 = AdeleMini.Height - 1
For y As Int16 = 0 To lastY
For x As int16 = 0 To lastX
If surf.Pixel(x,y) = &c000000 Then
AdeleMini.graphics.Pixel(x,y) = &cFFFFFF
End if
Next
Next
@Michel Bujardet : Thanks, I did: case is: 41938 - RGBsurface Mac 64bit bug
I will add the fact that setting the surface pixel is the problem. Thank you for helping get to the root of the problem.
[code] dim p as new picture (Adelemini.width,Adelemini.height,32)
p.Graphics.drawpicture Adelemini,0,0
Dim surf As RGBSurface = p.RGBSurface
dim origSurf as RGBSurface= Adelemini.RGBSurface // ref to original RGB surface
Dim lastX As Int16 = AdeleMini.Width - 1
Dim lastY As Int16 = AdeleMini.Height - 1
For y As Int16 = 0 To lastY
For x As int16 = 0 To lastX
If origSurf.Pixel(x,y) = &c000000 Then
surf.Pixel(x,y) = &cFFFFFF
End if
Next
Next