首先,对不起,我的英语不好,你好,我是这种论坛的新手,我的问题很头痛,好吧,我仍在寻找此页面和其他页面中的所有内容,我找不到解决方案,首先我需要创建屏幕截图并将其保存在 jpeg 字节数组中,我的代码很简单并创建 HBITMAP 但麻烦是将其转换为数组,这是我的代码:
int takeScreenShoot(){
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
HDC screenDC,memDC;
HBITMAP screenBITMAP;
screenDC= GetDC(NULL);
memDC= CreateCompatibleDC(screenDC);
int Height = GetSystemMetrics(SM_CYSCREEN);
int Width = GetSystemMetrics(SM_CXSCREEN);
screenBITMAP = CreateCompatibleBitmap(screenDC,Width,Height);
BitBlt(memDC,0,0,Width,Height,screenDC,0,0,SRCCOPY);
/*
use GDIplus for transform the image to JPEG and pass to a byte stream
or somethig like that
*/
ReleaseDC(NULL,memDC);
ReleaseDC(NULL,screenDC);
return 0;
}
好吧,这个代码如果用于练习,我尝试使用 GDI+ 中的 Image 类还有位图,但我找不到将其保存在字节数组中的方法,在某些页面中谈论使用 IStream 但我很难理解它,我需要有人以正确的方式指导我,预先感谢您的帮助:D
first of all sorry by my bad english, Hello i am new in this kind of forum, the question i have is a headache, well i still looking for everywere in this page and other, i can't no find the solution, first i need to create a screen capture and save it in a jpeg byte array, my code is simple and create the HBITMAP but the trouble is convert it to an array, here is my code:
int takeScreenShoot(){
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
HDC screenDC,memDC;
HBITMAP screenBITMAP;
screenDC= GetDC(NULL);
memDC= CreateCompatibleDC(screenDC);
int Height = GetSystemMetrics(SM_CYSCREEN);
int Width = GetSystemMetrics(SM_CXSCREEN);
screenBITMAP = CreateCompatibleBitmap(screenDC,Width,Height);
BitBlt(memDC,0,0,Width,Height,screenDC,0,0,SRCCOPY);
/*
use GDIplus for transform the image to JPEG and pass to a byte stream
or somethig like that
*/
ReleaseDC(NULL,memDC);
ReleaseDC(NULL,screenDC);
return 0;
}
well, this code if for practice, i try to use Image class from GDI+ and also Bitmap but i don't find the way to save it in a byte array, in some pages talk to use IStream but is dificult to me understand it, i need someone to direct me in the right way, thanks beforehand for the help :D
发布评论
评论(1)
您是否在寻找 GetDIBits?将依赖位图转换为 DIB然后将其流式传输到数组或文件或您想要的任何内容中。
有几个图像库也可以帮助提供想法。 CxImage,FreeImage,都具有将 HBITMAP(DDB 和 DIB)转换为字节流的功能。
Are you looking for GetDIBits? Convert a dependent bitmap into a DIB and then stream it into an array or file or whatever you want.
There are several image libraries that can help give ideas as well. CxImage, FreeImage, all have functions to convert HBITMAP (both DDB and DIB) into a stream-o-bytes.