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

Friendhosting全场VDS主机45折,虚拟主机4折,老用户续费9折

Friendhosting发布了今年黑色星期五促销活动,针对全场VDS主机提供45折优惠码,虚拟主机4折,老用户续费可获9折加送1个月使用时长,优惠后VDS最低仅€14.53/年起,商家支持PayPal、信用卡、支付宝等付款方式。这是一家成立于2009年的老牌保加利亚主机商,提供的产品包括虚拟主机、VPS/VDS和独立服务器租用等,数据中心可选美国、保加利亚、乌克兰、荷兰、拉脱维亚、捷克、瑞士和波...

GreenCloudVPS($30/年),500G大硬盘VPS,10Gbps带宽

GreenCloudVPS最近在新加坡DC2节点上了新机器,Dual Xeon Silver 4216 CPU,DDR4内存,10Gbps网络端口,推出了几款大硬盘VPS套餐,基于KVM架构,500GB磁盘起年付30美元。除了大硬盘套餐外,还加推了几款采用NVMe硬盘的常规套餐,最低年付20美元。不过需要提醒的是,机房非直连中国,尤其是电信用户ping值感人,包括新加坡DC1也是如此。大硬盘VPS...

RAKsmart便宜美国/日本/中国香港VPS主机 低至月$1.99 可安装Windows

RAKsmart 商家这几年还是在做事情的,虽然他们家顺带做的VPS主机并不是主营业务,毕竟当下的基础云服务器竞争过于激烈,他们家主营业务的独立服务器。包括在去年开始有新增多个数据中心独立服务器,包括有10G带宽的不限流量的独立服务器。当然,如果有需要便宜VPS主机的他们家也是有的,比如有最低月付1.99美元的美国VPS主机,而且可选安装Windows系统。这里商家有提供下面六款六月份的活动便宜V...

stretchdibits为你推荐
手机内存卡数据恢复手机存储数据恢复相机内存卡数据恢复相机内存卡坏了,数据有办法恢复吗?手机内存卡数据恢复软件免费下载手机存储卡被格式化了 ,谁有免费的恢复软件,能够恢复大部分文件腾讯空间首页腾讯空间主页哪去了麒麟820和980哪个好麒麟980和骁龙855那个好一点?集成显卡和独立显卡哪个好集成显卡和独立显卡什么区别?电脑杀毒软件哪个好电脑什么杀毒软件最好朗逸和速腾哪个好速腾和朗逸哪个更好?绝地求生加速器哪个好绝地求生哪个加速器好用一点,求推荐一个网页传奇哪个好玩有什么好玩的传奇类网页游戏?
域名网 qq云存储 wavecom uk2 域名优惠码 淘宝双十一2018 全能主机 浙江独立 湖南服务器托管 三拼域名 最好的空间 bgp双线 最好的免费空间 双十一秒杀 购买国外空间 申请免费空间和域名 闪讯官网 备案空间 阿里云官方网站 中国域名 更多