Click here to Skip to main content
15,845,681 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

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;



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?

Updated 23-Oct-10 4:03am

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.
Share this answer
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.
Share this answer
Coburner 23-Oct-10 11:18am    
what I meant to say was that I hadn't done any projects regarding bitmaps. I am familiar with plain C++ programming though. Well in any case.. what would you suggest as the best way to go about this? I presume that Dev-c++ does not support MFC and Microsoft's VS is expen$ive

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900