我正在工作的程序要求我将两个图像层叠在一起(z索引将是1个数字)。顶层是一张黑色图片(Png),底层是一张你可以从google上拉出来的普通图片。假设我从之前输入的数据库中提取了一组像素(例如100个像素);我希望这100个像素变为透明。我当前的代码通过将像素更改为纯白色来响应。有人有什么建议吗?
此代码片段表示从数据库中提取的特定像素。
DataSet ds = new DataSet();
SqlCommand sqlRead = new SqlCommand("SELECT * FROM PIXEL", con);
List<int> pixelIds = new List<int>();
using (SqlDataReader read = sqlRead.ExecuteReader())
{
while (read.Read())
{
int pixel = Convert.ToInt32(read[0]);
pixelIds.Add(pixel);
int yaxis = Convert.ToInt32(pixel) / 1000;
int xaxis = Convert.ToInt32(pixel) % 1000;
image1.SetPixel(xaxis, yaxis, Color.Transparent);
}
}
发布于 2016-04-27 19:38:19
解决了。我要做的就是把Color.Transparent
改成Color.Brown
,然后在下面写image1.MakeTransparent(Color.Brown)
,这样就能完美地工作了。感谢你们所有人的回复。
https://stackoverflow.com/questions/36887117
复制相似问题