[Gambas-user] About Image.Pixel

Bruce Steers bsteers4 at gmail.com
Tue Aug 15 13:35:43 CEST 2023


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/b37879d7/attachment.htm>


More information about the User mailing list