1个回答
展开全部
举例说明吧
// Create a Bitmap object from an image file.
Bitmap myBitmap = new Bitmap("Grapes.jpg");
// Get the color of a pixel within myBitmap.
Color pixelColor = myBitmap.GetPixel(50, 50);
// Create a Bitmap object from an image file.
Bitmap myBitmap = new Bitmap("Grapes.jpg");
// Get the color of a pixel within myBitmap.
Color pixelColor = myBitmap.GetPixel(50, 50);
追问
我想把每个color对象放入byte数组然后
MemoryStream ms = new MemoryStream(byt);
Image img = Image.FromStream(ms);
可以吗 要怎样把color转换成byte
追答
给你一个读取图像像素的函数,满意请采纳:
public static bool GetRGB(Bitmap Source, out int[,] R, out int[,] G, out int[,] B)
{
try
{
int iWidth = Source.Width;
int iHeight = Source.Height;
R = new int[iHeight, iWidth];
G = new int[iHeight, iWidth];
B = new int[iHeight, iWidth];
for (int i = 0; i < iHeight; i++)
{
for (int j = 0; j < iWidth; j++)
{
Color colCurr = Source.GetPixel(j, i);
R[i, j] = colCurr.R;
G[i, j] = colCurr.G;
B[i, j] = colCurr.B;
}
}
return true;
}
catch (Exception)
{
R = null;
G = null;
B = null;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询