[Gambas-user] About Image.Pixel
T Lee Davidson
t.lee.davidson at gmail.com
Tue Aug 15 20:28:27 CEST 2023
On 8/15/23 12:44, Bruce Steers wrote:
>
>
> On Tue, 15 Aug 2023 at 16:55, vuott--- via User <user at lists.gambas-basic.org <mailto:user at lists.gambas-basic.org>> wrote:
>
> Maybe....
>
>
> Public Sub Form_Open()
>
> Dim hImg As New Image(1, 1, Color.Red)
>
> Print "red = "; Color.Red
>
> Print hImg.Pixels[0]
> Print
> Print Val("&" & Hex(hImg.Pixels[0], 6) & "&"), Hex(hImg.Pixels[0], 8)
> Print
> Print hImg[0, 0]
>
> End
> ________________
>
>
>
> Hehe, yes i was absolutely 100% sure i was not doing it the easiest way, and maybe not even correctly ;)
>
> Respects
> BruceS
That would work for a color with full opacity, but not necessarily for a color with any transparency.
But, when playing around with this, I am getting some weirdness:
This code (using Qt5):
[code]
Public Sub Form_Open()
Dim hImg As New Image(1, 1, Color.Red)
Print Hex(Color.Red)
Print SizeOf(Color.Red)
Print Hex(hImg.Pixels[0])
' Print SizeOf(hImg.Pixels[0]) ' <--- this causes a segmentation fault
End
[/code]
Produces:
FF0000
8
FFFFFFFFFFFF0000
!SegFault
The size of Color.Red is 8 bytes, 64 bits? Shouldn't it be 4 bytes for 32 bits?
Am I missing something, or is my Gambas corrupted?
--
Lee
More information about the User
mailing list