stretchdibits怎么用VC把bmp图片的数据信息还原为图片并显示

stretchdibits  时间:2021-01-10  阅读:()

StretchDIBits()函数中CONST VOID *lpBits是什么意思?

指向一个BYTE类型的数组,数组中记录了要拷贝到CBitmap对象的位值。

如何使用opencv获取已经灰度化二值化的一张黑色图片中的一个亮点的具体像素坐标

OpenCV 整个项目的结构图: 编写DetectFaceDemo.java,代码如下: [java] view plaincopyprint? .njupt.zhb.test; .opencv.core.Core; .opencv.core.Mat; .opencv.core.MatOfRect; .opencv.core.Point; .opencv.core.Rect; .opencv.core.Scalar; .opencv.highgui.Highgui; .opencv.objdetect.CascadeClassifier; // // Detects faces in an image, draws boxes around them, and writes the results // to "faceDetection.png". // public class DetectFaceDemo { public void run() { System.out.println(" Running DetectFaceDemo"); System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath()); // Create a face detector from the cascade file in the resources // directory. //CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath()); //Mat image = Highgui.imread(getClass().getResource("lena.png").getPath()); //注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误 /* * Detected 0 faces Writing faceDetection.png libpng warning: Image * width is zero in IHDR libpng warning: Image height is zero in IHDR * libpng error: Invalid IHDR data */ //因此,我们将第一个字符去掉 String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1); CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath); Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1)); // Detect faces in the image. // MatOfRect is a special container class for Rect. MatOfRect faceDetections = new MatOfRect(); faceDetector.detectMultiScale(image, faceDetections); System.out.println(String.format("Detected %s faces", faceDetections.toArray().length)); // Draw a bounding box around each face. for (Rect rect : faceDetections.toArray()) { Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0)); } // Save the visualized detection. String filename = "faceDetection.png"; System.out.println(String.format("Writing %s", filename)); Highgui.imwrite(filename, image); } } .njupt.zhb.test; .opencv.core.Core; .opencv.core.Mat; .opencv.core.MatOfRect; .opencv.core.Point; .opencv.core.Rect; .opencv.core.Scalar; .opencv.highgui.Highgui; .opencv.objdetect.CascadeClassifier; // // Detects faces in an image, draws boxes around them, and writes the results // to "faceDetection.png". // public class DetectFaceDemo { public void run() { System.out.println(" Running DetectFaceDemo"); System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath()); // Create a face detector from the cascade file in the resources // directory. //CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath()); //Mat image = Highgui.imread(getClass().getResource("lena.png").getPath()); //注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误 /* * Detected 0 faces Writing faceDetection.png libpng warning: Image * width is zero in IHDR libpng warning: Image height is zero in IHDR * libpng error: Invalid IHDR data */ //因此,我们将第一个字符去掉 String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1); CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath); Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1)); // Detect faces in the image. // MatOfRect is a special container class for Rect. MatOfRect faceDetections = new MatOfRect(); faceDetector.detectMultiScale(image, faceDetections); System.out.println(String.format("Detected %s faces", faceDetections.toArray().length)); // Draw a bounding box around each face. for (Rect rect : faceDetections.toArray()) { Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0)); } // Save the visualized detection. String filename = "faceDetection.png"; System.out.println(String.format("Writing %s", filename)); Highgui.imwrite(filename, image); } } 3.编写测试类: [java] view plaincopyprint? .njupt.zhb.test; public class TestMain { public static void main(String[] args) { System.out.println("Hello, OpenCV"); // Load the native library. System.loadLibrary("opencv_java246"); new DetectFaceDemo().run(); } } //运行结果: //Hello, OpenCV // //Running DetectFaceDemo ///E:/eclipse_Jee/workspace/JavaOpenCV246//njupt/zhb/test/lbpcascade_frontalface.xml //Detected 8 faces //Writing faceDetection.png .njupt.zhb.test; public class TestMain { public static void main(String[] args) { System.out.println("Hello, OpenCV"); // Load the native library. System.loadLibrary("opencv_java246"); new DetectFaceDemo().run(); } } //运行结果: //Hello, OpenCV // //Running DetectFaceDemo ///E:/eclipse_Jee/workspace/JavaOpenCV246//njupt/zhb/test/lbpcascade_frontalface.xml //Detected 8 faces //Writing faceDetection.png

DIB是什么格式

DIB设备无关位图文件,这是一种文件格式,是为了保证用某个应用程序创建的位图图形可以被其它应用程序装载或显示一样。

DIB的与设备无关性主要体现在以下两个方面:DIB的颜色模式与设备无关。

例如,一个256色的DIB即可以在真彩色显示模式下使用,也可以在16色模式下使用。

256色以下(包括256色)的DIB拥有自己的颜色表,像素的颜色独立于系统调色板。

由于DIB不依赖于具体设备,因此可以用来永久性地保存图象。

DIB一般是以*.BMP文件的形式保存在磁盘中的,有时也会保存在*.DIB文件中。

运行在不同输出设备下的应用程序可以通过DIB来交换图象。

/view/18734.htm

怎么用VC把bmp图片的数据信息还原为图片并显示

用StretchDIBits函数。

假设你的数据存储在下面两个结构中: BITMAPINFO bmi PBYTE pbits 在视图类的OnDraw函数中添加一句: ::StretchDIBits(pDC->GetSafeHdc(), 0, 0, bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight, 0, 0, bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight, pbits, bmi, DIB_RGB_COLORS, SRCCOPY ); 即可

Virtono:圣何塞VPS七五折月付2.2欧元起,免费双倍内存

Virtono是一家成立于2014年的国外VPS主机商,提供VPS和服务器租用等产品,商家支持PayPal、信用卡、支付宝等国内外付款方式,可选数据中心共7个:罗马尼亚2个,美国3个(圣何塞、达拉斯、迈阿密),英国和德国各1个。目前,商家针对美国圣何塞机房VPS提供75折优惠码,同时,下单后在LET回复订单号还能获得双倍内存的升级。下面以圣何塞为例,分享几款VPS主机配置信息。Cloud VPSC...

Sharktech10Gbps带宽,不限制流量,自带5个IPv4,100G防御

Sharktech荷兰10G带宽的独立服务器月付319美元起,10Gbps共享带宽,不限制流量,自带5个IPv4,免费60Gbps的 DDoS防御,可加到100G防御。CPU内存HDD价格购买地址E3-1270v216G2T$319/月链接E3-1270v516G2T$329/月链接2*E5-2670v232G2T$389/月链接2*E5-2678v364G2T$409/月链接这里我们需要注意,默...

弘速云香港VPSVPS线路有CN2+BGP、CN2 GIA,KVM虚拟化架构,裸金属月付564元

弘速云怎么样?弘速云是创建于2021年的品牌,运营该品牌的公司HOSU LIMITED(中文名称弘速科技有限公司)公司成立于2021年国内公司注册于2019年。HOSU LIMITED主要从事出售香港vps、美国VPS、香港独立服务器、香港站群服务器等,目前在售VPS线路有CN2+BGP、CN2 GIA,该公司旗下产品均采用KVM虚拟化架构。可联系商家代安装iso系统。点击进入:弘速云官方网站地址...

stretchdibits为你推荐
免费卡巴斯基杀毒软件十大终身免费杀毒软件?非主流桌面背景图片22寸非主流桌面壁纸少儿英语哪个好少儿英语哪种的好?少儿英语哪个好少儿英语,那个好一些?炒股软件哪个好用用手机股票软件哪个好雅思和托福哪个好考雅思和托福哪个好考一点云盘哪个好免费的网盘哪个好用啊?首选dns服务器首选DNS服务器和备用DNS服务器有什么区别?360云盘登录360云盘登陆账号360云盘同步版360云盘和360云盘同步版有甚么区分同步版占用电脑空间?
域名解析文件 主机点评 tier 国外服务器 idc评测网 php探针 win8.1企业版升级win10 eq2 一元域名 ntfs格式分区 可外链网盘 南通服务器 爱奇艺vip免费试用7天 免费高速空间 百度云1t 国外免费asp空间 ftp免费空间 免费网页空间 银盘服务是什么 个人免费主页 更多