I doubt it's another language (assuming you meant Bitmap::FromHBITMAP), the Bitmap class is just from some image library.
You'll need to choose an image manipulation library or write your own. How you do it (whatever "it" is) depends on the library.
Thank you very much. I have no experience and your helping is a big step forward, thanks.
Now i will look for an "image library" then.
What im trying to do is get the bitmap from HBITMAP so i can get the rgb values of some pixels and also save the whole image in a .bmp file.
For the rgb values, i would use getPixel(x,y), but for saving to file i still don't have a clue on how to do it without using MFC/ATL.
Can you suggest me any viable way of achieving these 2?
I believe FreeImagePlus (which is a C++ wrapper for FreeImage) can construct an image object from a bitmap handle as well. FreeImage(Plus) gives you functions that allow you to easily access the pixels, manipulate the image in other ways and save it in many different image formats.
If you want to to it without FreeImage, I'd suggest googling "winapi save bitmap to file".
Ok, im trying with GetDIBits but i cant make it work.
It always returns senseless values.
I think im missing the purpose of HDC here. Can someone explain this please? I mean, what's it for???
Note:
1) The image is a screenshot which i take just before running the code by pressing 'PrtScreen' button on the keyboard.
2) GetDIBits scans line 500 which, since im on a resolution of 1280x1024, is approximately in the middle of the screen.
3) Color depth is 32bits.
That sounds weird to me: isnt it that the bitmap is copied in hBitmap when GetClipboardData is called?
Anyway, i did move CloseClipboard to the end. And still returns senseless values.
Bitmap is a class defined in [url=http://msdn.microsoft.com/en-us/library/ms533798(VS.85).aspx]GDI+ Library[/url].
To use it, you have to do the following:
- include <ghiplus.h> header;
- link your project to gdiplus.lib;
- initialize GDI+ library by a call to GdiplusStartup;
- use Gdiplus namespace anytime you are using GDI+ stuff;
- read GDI+ documentation and examples (see the links below).
You don't get a copy of the bitmap when calling GetClipboardData. A handle is something like a pointer. That's why you need to make sure no one else is messing with the clipboard by keeping it open.
Thanks a lot Athar. Im able to save the .bmp file now but i still have questions on the rgb values that i get and the way i get them.
Please, let's continue on this thread if you don't mind: http://www.cplusplus.com/forum/beginner/26816/.
On a side not, how do you link addresses on this forum?
Thanks