RasterImage.LoadArgb32Pixels
内容
[
隐藏
]RasterImage.LoadArgb32Pixels method
加载 32 位 ARGB 像素。
public int[] LoadArgb32Pixels(Rectangle rectangle)
| 参数 | 类型 | 描述 |
|---|---|---|
| 矩形 | Rectangle | 用于加载像素的矩形。 |
返回值
已加载的 32 位 ARGB 像素数组。
示例
以下示例展示了如何加载和处理光栅图像的像素。像素以 32 位整数值表示。例如,考虑统计图像中完全透明像素的问题。
[C#]
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\alpha.png"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// 加载整幅图像的像素。图像的任意矩形区域都可以作为 Aspose.Imaging.RasterImage.LoadArgb32Pixels 方法的参数指定。
int[] pixels = rasterImage.LoadArgb32Pixels(rasterImage.Bounds);
int count = 0;
foreach (int pixel in pixels)
{
int alpha = (pixel >> 24) & 0xff;
if (alpha == 0)
{
count++;
}
}
System.Console.WriteLine("The number of fully transparent pixels is {0}", count);
System.Console.WriteLine("The total number of pixels is {0}", image.Width * image.Height);
}
另请参见
- struct Rectangle
- class RasterImage
- namespace Aspose.Imaging
- assembly Aspose.Imaging