用于裁剪位图图像的c ++代码,忽略54字节标头 [英] c++ code to crop a bitmap image ignoring the 54 byte header

查看:40
本文介绍了用于裁剪位图图像的c ++代码,忽略54字节标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的位图图像包含白色背景中的对象..如何使用c ++在位图图像中裁剪对象..也忽略54字节位图头... plz hlp!伙计们试图尽快...





提前感谢..

解决方案

有两种主要方法可以解决您的问题:



(a)访问位图数据并手动提取所需的矩形。这需要知道每个像素的大小,每行的长度(包括松弛字节),存储行的顺序(从上到下或从下到上)以及可用行的数量。所有这些都包含在BITMAP结构中。



(b)将位图加载到内存DC中,创建第二个内存DC并加载目标大小的位图进入它,然后从第一个DC到第二个DC具有合适的偏移量和大小。



两种方式都可以。您将不得不研究Windows的位图API并了解BITMAP结构,位图在内存中的存储方式以及bitblt的工作方式。


参见 https://www.google.com/search?q=bitmap%20basics%20c%2B%2B [ ^ ]。

assuming i have a bitmap image containing an object in a white background ..how to crop the object in the bitmap image using c++..also ignore the 54 byte bitmap header..plz hlp!guys try to rply asap..


thanks in advance..

解决方案

There are two principal ways to solve your question:

(a) Access the bitmap data and extract the desired rectangle by hand. That requires to know the size of each pixel, the length of each line (including slack bytes), the sequence in which lines are stored (top-to-bottom or bottom-to-top), and the number of available lines. All these things are contained in the BITMAP structure.

(b) Load the bitmap into a memory DC, create a second memory DC and load a bitmap of the target size into it, then bitblt from the first into the second DC with suitable offsets and sizes.

Either way will work. You will have to study the bitmap API of windows and learn about the BITMAP structure, the way in which bitmaps are stored in memory, and how bitblt works.


See https://www.google.com/search?q=bitmap%20basics%20c%2B%2B[^].


这篇关于用于裁剪位图图像的c ++代码,忽略54字节标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆