-4

How to convert Color to argb as array int

pseudo example

Color color=nw.GetPixel(i, j);
int[] argbarray = color.toARGBArray();

result:
argbarray[0]=255  (alpha)
argbarray[1]=241  (red)
argbarray[2]=128  (green)
argbarray[3]=69   (blue)
user2812337
  • 29
  • 1
  • 6

1 Answers1

3

I searched through Google, he did not give the sense of anything that I needed

I googled C# color bytes and this is the first result Convert color to byte value

still no sense?

BTW: My way would be:

Color color = Color.FromArgb(1,2,3,4);  //alpha,red, green, blue
var argbarray = BitConverter.GetBytes(color.ToArgb())
                .Reverse()
                .ToArray();

argbarray[0]=1  (alpha)
argbarray[1]=2  (red)
argbarray[2]=3  (green)
argbarray[3]=4  (blue)
Community
  • 1
  • 1
EZI
  • 15,209
  • 2
  • 27
  • 33
  • 1
    My queries are different from the above "I googled C# color bytes and this is the first result Convert color to byte value" – user2812337 Mar 28 '15 at 23:57
  • @user2812337 than explain it. I see no difference. Above code does exactly what you expect from `toARGBArray` in your pseudo code – EZI Mar 28 '15 at 23:58
  • now I'll know, and other users will find this answer – user2812337 Mar 28 '15 at 23:58
  • example https://www.google.ru/search?ie=UTF-8&hl=ru&q=Color%20to%20int&gws_rd=ssl#newwindow=1&hl=ru&q=c%23+Color+to+int – user2812337 Mar 29 '15 at 00:00
  • @user2812337 What should I understand from your comments? *"I am so ignorant that I can even understand a correct answer posted"* ? – EZI Mar 29 '15 at 00:03
  • no I meant that my inquiries in Google were incorrect – user2812337 Mar 29 '15 at 00:09