C++
private void getgif()
{
Image img = Image.FromFile(@"C:\1.Bmp");
Bitmap bm = new Bitmap(img.Width, img.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
Image img2 = Image.FromFile(@"C:\2.Bmp");
Image bgbmp = new Bitmap(img2);
img.Dispose();
Bitmap bImage = new Bitmap(bgbmp, 102, 126);
var color = new Color(); //定义一个Color对象,将其存储像素值
for (int i = 0; i < 102; i++) //得到图片的宽度
{
for (int j = 0; j < 126; j++) //得到图片的高度
{
color = bImage.GetPixel(i, j); //得到二维数组中a[i,j]的像素值
//判断该像素值是否接近白色,如果是,那么将其转换成透明色(以RGB>250为界限
if (int.Parse(color.B.ToString()) >= 250 && int.Parse(color.R.ToString()) >= 250 && int.Parse(color.G.ToString()) >= 250)
bImage.SetPixel(i, j, Color.Transparent); //设置背景为透明色
}
}
Graphics g = Graphics.FromImage(bm);
g.Clear(Color.White);
g.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel);
g.DrawImage(bImage, new Rectangle(0, 0, bImage.Width, bImage.Height), 0, 0, bImage.Width, bImage.Height, GraphicsUnit.Pixel);
g.DrawString("addasdasdasd", new Font("黑体", 20), new SolidBrush(Color.Black), new Point(50, 10));
g.Dispose();
bm.Save(@"C:\photo.jpg");
}把上面C#的代码转为C++代码??? 因为是驱动开发,在dll里调用dgi 直接使用GetHDC()得不得指针。 求大神帮忙。
...全文
相关推荐
C++ .h和.cpp文件总结
总结了.h文件能做什么,.cpp文件能做什么,总结了.h文件的本质,方便新手在遇到文件包含、类型声明、变量定义时能理清.h与.cpp关系,纯属个人总结文档。
cpp代码-C++基础
cpp代码-C++基础
33个c++重要知识总结(cpp代码)
c++基础知识复习,包含了33个cpp文件,每个文件包含特定主题的知识回顾,使用特定案例重温某些不常用但是重要的算法或函数的使用方法,含注释。
c++版yaml库yaml-cpp
c++版yaml库yaml-cpp
C++基于LOG4CPP的使用封装库
代码是C++,基于LOG4CPP进行封装日志,适用于Linux环境,使用过程时,对其进行继承即可套用其结构


