[Gambas-user] About Image.Pixel
vuott at tutanota.com
vuott at tutanota.com
Tue Aug 15 17:45:01 CEST 2023
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
________________
15 ago 2023, 13:37 da bsteers4 at gmail.com:
>
>
> On Tue, 15 Aug 2023 at 12:24, Bruce Steers <> bsteers4 at gmail.com> > wrote:
>
>>
>>
>> On Tue, 15 Aug 2023 at 12:18, Bruce Steers <>> bsteers4 at gmail.com>> > wrote:
>>
>>>
>>>
>>> On Tue, 15 Aug 2023 at 12:13, Bruce Steers <>>> bsteers4 at gmail.com>>> > wrote:
>>>
>>>>
>>>>
>>>> On Mon, 14 Aug 2023 at 23:37, Bruce Steers <>>>> bsteers4 at gmail.com>>>> > wrote:
>>>>
>>>>>
>>>>>
>>>>> On Mon, 14 Aug 2023, 21:19 Fabien Bodard, <>>>>> gambas.fr at gmail.com>>>>> > wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Dim hImg As New Image(1, 1, Color.red)
>>>>>> dim a as Integer[]
>>>>>>
>>>>>> a = hImg.Pixels
>>>>>> Print a[0]
>>>>>> Print hImg[0, 0]
>>>>>>
>>>>>> result :
>>>>>> -65536
>>>>>> 16711680
>>>>>>
>>>>>>
>>>>>> Why ?
>>>>>>
>>>>>> --
>>>>>> Fabien Bodard
>>>>>>
>>>>>
>>>>> According to wiki Image[x,y] returns a "colour"
>>>>> Image.pixels[n] will be from an array of "32 bits integers"
>>>>>
>>>>> I don't understand it but seems could be a difference?
>>>>>
>>>>>
>>>>> Respects
>>>>> BruceS
>>>>>
>
> Final post..
>
> I've successfully got the Pixels[] data reading the same as the Image[] data
>
>
> Public Sub Form_Open()
>
> Dim hImg As New Image(1, 1, Color.red)
>
> hImg.Format = "BGRA"
>
> Dim aInt As Integer[]
>
> Print "red = "; Color.Red
> aInt = hImg.Pixels
>
> Print aInt[0]
> Print hImg[0, 0]
> Print ""
>
> Dim A, R, G, B As String
>
> B = Hex(255 - Lsr(aInt[0], 24) And &HFF, 2)
> G = Hex(Lsr(aInt[0], 16) And &HFF, 2)
> R = Hex(Lsr(aInt[0], 8) And &HFF, 2)
> A = Hex(aInt[0] And &HFF, 2)
> Print Val("&h" & b & g & r & a)
>
> B = Hex(Lsr(hImg[0, 0], 24) And &HFF, 2)
> G = Hex(Lsr(hImg[0, 0], 16) And &HFF, 2)
> R = Hex(Lsr(hImg[0, 0], 8) And &HFF, 2)
> A = Hex(hImg[0, 0] And &HFF, 2)
>
> Print Val("&h" & b & g & r & a)
>
> End
>
> Results...
> red = 16711680
> -65536
> 16711680
>
> 16711680
> 16711680
>
> BruceS
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230815/d630ee1f/attachment.htm>
More information about the User
mailing list