将图像流转换为int [] argb [英] converts image stream to int[] argb

查看:71
本文介绍了将图像流转换为int [] argb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何将图像流转换为int [] argb?
以及argb和bgr有什么区别?

how i can converts image stream to int[] argb ?
and what the differents between argb and bgr ?

推荐答案

将ARGB表示为int[]是一个坏主意.颜色分量由8位或16位值表示,具体取决于您可以从位图文件中读取或为新位图定义的像素格式",但是int是32位带符号的值.您最好使用结构数组.

BGR(很可能;您没有提供问题中的所有详细信息,请参见下面)与(红色,绿色,蓝色,RGB)相同,但用于某些像素格式的组件顺序不同. > ARGB与RGB相同,但带有称为"alpha"的附加组件,代表像素的透明度".每个组件的位数取决于像素格式.

考虑到原始问题的详细程度,仅此而已,但这对您来说应该足够了.您没有向我们解释您使用的想象库.可能是System.Drawing,WPF或其他名称.无论如何,如果您了解基本思想,则可以在MSDN帮助提供的库文档中轻松找到更多详细信息.

祝你好运,
—SA
This is a bad idea to represent ARGB as int[]. The color components are represented by 8 or 16-bit values, depending on "pixel format" you can read from the bitmap file or define for a new bitmap, but int is a 32-bit signed value. You should better use an array of structures.

BGR is (most probably; you did not provide all the details in the question, please see below) it the same as (Red-Green-Blue, RGB), but in different order of components used for some pixel formats.
ARGB is the same as RGB, but with additional component called "alpha", which represent "transparency" of a pixel. The number of bits per component depends on pixel format.

That''s all, considering the level of detail of the original question, but that should be enough for you. You did not explain us what imagine library do you use. It could be System.Drawing, WPF or something else. Anyway, if you understand the basic ideas, you can easily find further detail in the library documentation provided by MSDN help.

Good luck,
—SA


这是一个很好的示例,说明了如何在C#中锁定和读取/写入位图的位:
BGR和ARGB之间的区别:
旧的winapi和GDI东西以BGR格式将对分数据存储在内存中,这基本上与位图文件中使用的格式相同.调色板化(8位或更少位)的bmp文件具有一个调色板,该调色板由
RGBQUAD [ ^ ]结构,像素仅为1 4或8位索引到该数组.当您具有32位位图时,则没有调色板,但是每个像素都具有与RGBQUAD结构相同的格式. BGRA和ARGB之间的区别在于它们将红色,绿色,蓝色和alpha分量存储在整数的不同位范围内.
This is a good example on how to lock and read/write the bits of a bitmap in C#: Work with bitmaps faster in C#[^]. Note that 24/32 bit bitmaps contain the pixel data in BGR format. I would questions the "faster" part of the title of the article depending on your goals. This can come handy for example if you are implementing some image processing algorithms.

Differences between BGR and ARGB:
The old winapi and GDI stuff stores dibsection data in BGR format in memory, this is basically the same as the format used in bitmap files. palettized (8 or less bit) bmp files have a palette consisting of an array of RGBQUAD[^] structures and the pixels are just 1, 4, or 8 bit indices to this array. When you have a 32 bit bitmap then you don''t have a palette but every pixel has the same format as the RGBQUAD structure. The difference between BGRA and ARGB is that they store the red, green, blue and alpha components in different bitranges of the integer.


这篇关于将图像流转换为int [] argb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆