位图和Dev-c ++ [英] Bitmaps and Dev-c++
问题描述
大家好,
我从来没有处理过位图处理.我在Google上搜索了一段时间,但找不到适合我的dev-cpp的任何东西.
我要在此处完成的任务是模拟用户按下打印屏幕按钮,将剪贴板数据加载到位图,将其裁剪并缩放为特定大小,然后将其与保存在程序目录中的bmp文件进行比较.
这应该将我的bmp文件加载到位图
Hey guys,
I have never dealt with bitmap handling whatsoever. I googled for some time yet wasn''t able to find anything that would work with my dev-cpp.
What I intend to accomplish here is to emulate a user pressing the printscreen button, loading the clipboard data to a bitmap, crop&pan it to a certain size and compare it to a bmp file saved in my program directory.
this should load my bmp file to a bitmap
#include <iostream>
#include <fstream>
#include <windows.h>
using namespace std;
int main(){
unsigned char Header[0x435],image[256][256];
FILE* fp=fopen("Unbenannt.bmp","r");
fread(Header,1,0x435,fp); // copy image header to Header array
fseek(fp,0x436,SEEK_SET); // Move file pointer to start of image data
fread(image,1,256*256,fp); // read image data and copy to ImageIn1[][] array
fclose(fp);
这应该将剪贴板数据加载到位图
and this should load the clipboard data to the bitmap
if ( OpenClipboard(NULL) )
{
//Get the clipboard data
HBITMAP handle = (HBITMAP)GetClipboardData(CF_BITMAP);
CBitmap * bm = CBitmap::FromHandle(handle);
ClientDC cdc(this);
HDC dc;
dc.CreateCompatibleDC(&cdc);
dc.SelectObject(bm);
cdc.BitBlt(0,0,200,200,&dc,0,0,SRCCOPY);
CloseClipboard();
}
但是它报告了诸如CBitmap,FromHandle,ClientDC未声明的问题
我没有经验,所以不知道该怎么办.有人可以帮我把它成型吗?
谢谢
however it reports problems such as CBitmap, FromHandle, ClientDC undeclared
I don''t know what to do as I have no experience. Could someone please help me get this into shape?
Thanks
推荐答案
似乎您正在尝试在控制台程序中使用MFC Window类.您还提到您没有经验,因此在着手此类项目之前花一些时间学习Windows编程的基础可能会更好.互联网上有很多资源可以为您提供帮助:请查看 MSDN [ ^ ]是一个很好的起点,有用的文章此处 [
It looks as though you are trying to use MFC Window classes in a console program. You also mention that you have no experience so it would perhaps be better to spend some time learning the basics of Windows programming before embarking on a project such as this. There are lots of resources on the internet to help you: take a look at MSDN[^] as a good starting point, also lots of useful articles here[^] on CodeProject.
我建议您获取免费的Microsoft Visual C ++ Express [
I would suggest getting a copy of the free Microsoft Visual C++ Express[^]. Although it does not include support for MFC it supports the full Win32 API and makes it fairly simple to produce graphical programs.
这篇关于位图和Dev-c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!