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 ); 即可

腾讯云轻量服务器老用户续费优惠和老用户复购活动

继阿里云服务商推出轻量服务器后,腾讯云这两年对于轻量服务器的推广力度还是比较大的。实际上对于我们大部分网友用户来说,轻量服务器对于我们网站和一般的业务来说是绝对够用的。反而有些时候轻量服务器的带宽比CVM云服务器够大,配置也够好,更有是价格也便宜,所以对于初期的网站业务来说轻量服务器是够用的。这几天UCLOUD优刻得香港服务器稳定性不佳,于是有网友也在考虑搬迁到腾讯云服务器商家,对于轻量服务器官方...

DogYun27.5元/月香港/韩国/日本/美国云服务器,弹性云主机

DogYun怎么样?DogYun是一家2019年成立的国人主机商,称为狗云,提供VPS及独立服务器租用,其中VPS分为经典云和动态云(支持小时计费及随时可删除),DogYun云服务器基于Kernel-based Virtual Machine(Kvm)硬件的完全虚拟化架构,您可以在弹性云中,随时调整CPU,内存,硬盘,网络,IPv4路线(如果该数据中心接入了多条路线)等。DogYun弹性云服务器优...

香港最便宜的vps要多少钱?最便宜的香港vps能用吗?

香港最便宜的vps要多少钱?最便宜的香港vps能用吗?香港vps无需备案,整体性能好,而且租用价格便宜,使用灵活,因为备受站长喜爱。无论是个人还是企业建站,都比较倾向于选择香港VPS。最便宜的香港vps能用吗?正因为有着诸多租用优势,香港VPS在业内颇受欢迎,租用需求量也在日益攀升。那么,对于新手用户来说,香港最便宜的vps租用有四大要点是务必要注意的,还有易探云香港vps租用最便宜的月付仅18元...

stretchdibits为你推荐
浏览器哪个好大家用过的哪种浏览器最好用?用过多种浏览器的说麒麟820和980哪个好4415y处理器和麒麟980哪个好?燃气热水器和电热水器哪个好燃气热水器好还是电热水器好?手机浏览器哪个好手机什么浏览器最好用?手机管家哪个好手机管家哪个好红茶和绿茶哪个好红茶和绿茶,哪个好?网络机顶盒哪个好什么牌子的网络机顶盒最好云盘哪个好免费的网盘哪个好?更大、更安全、更实用?网页qq空间登录网页查看qq空间辽宁联通营业厅辽宁移动网上营业厅进入办法
已备案域名 网站虚拟主机空间 如何注销域名备案 仿牌空间 息壤备案 vps.net jsp主机 linode 谷歌香港 申请空间 建立邮箱 柚子舍官网 789电视 hkg metalink 空间登陆首页 论坛主机 秒杀品 iki 免费个人网页 更多