91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

VC GDI+ 窗口截圖內存BMP轉JPG,壓縮、JPG再轉IStream流,IStream流再轉 BYTE 上體見 http://blog.csdn.net/q610098308/article/details/78181933

資源截圖

代碼片段和文件信息

/**
?@file?mem_image.cpp
?@author?Kevin?Lynx
?@brief?to?load/save?images?from/to?memory?based?on?GDI+
*/
#include?“mem_image.h“
#include?

static?int?GetEncoderClsid(?const?WCHAR?*format?CLSID?*pClsid?)
{
UINT?num?=?0?size?=?0;
Gdiplus::ImageCodecInfo?*pImageCodecInfo?=?NULL;?
Gdiplus::GetImageEncodersSize(?&num?&size?);
if(?size?==?0?)
{
return?-1;
}
pImageCodecInfo?=?(Gdiplus::ImageCodecInfo*)?malloc(?size?);
Gdiplus::GetImageEncoders(?num?size?pImageCodecInfo?);
for(?UINT?i?=?0;?i? {
if(?wcscmp(?pImageCodecInfo[i].MimeType?format?)?==?0?)
{
*pClsid?=?pImageCodecInfo[i].Clsid;
free(?pImageCodecInfo?);
return?i;
}
}
free(?pImageCodecInfo?);
return?-1;
}

static?bool?mem_to_global(?const?void?*buf?size_t?size?HGLOBAL?global?)
{
void?*dest?=?::GlobalLock(?global?);
if(?dest?==?NULL?)
{
return?false;
}
memcpy(?dest?buf?size?);
::GlobalUnlock(?global?);
return?true;
}

static?bool?stream_to_mem(?IStream?*stream?void?**outbuf?size_t?*size?)
{
ULARGE_INTEGER?ulnSize;
LARGE_INTEGER?lnOffset;
lnOffset.QuadPart?=?0;
/*?get?the?stream?size?*/
if(?stream->Seek(?lnOffset?STREAM_SEEK_END?&ulnSize?)?!=?S_OK?)
{
return?false;
}
if(?stream->Seek(?lnOffset?STREAM_SEEK_SET?NULL?)?!=?S_OK?)
{
return?false;
}

/*?read?it?*/
*outbuf?=?malloc(?(size_t)ulnSize.QuadPart?);
*size?=?(size_t)?ulnSize.QuadPart;
ULONG?bytesRead;
if(?stream->Read(?*outbuf?(ULONG)ulnSize.QuadPart?&bytesRead?)?!=?S_OK?)
{
free(?*outbuf?);
return?false;
}

return?true;
}

Gdiplus::Image?*mi_from_memory(?const?void?*buf?size_t?size?)
{
IStream?*stream?=?NULL;
HGLOBAL?global?=?::GlobalAlloc(?GMEM_MOVEABLE?size?);
if(?global?==?NULL?)
{
return?NULL;
}
/*?copy?the?buf?content?to?the?HGLOBAL?*/
if(?!mem_to_global(?buf?size?global?)?)
{
::GlobalFree(?global?);
return?NULL;
}
/*?get?the?IStream?from?the?global?object?*/
if(?::CreateStreamOnHGlobal(?global?TRUE?&stream?)?!=?S_OK?)
{
::GlobalFree(?global?);
return?NULL;
}
/*?create?the?image?from?the?stream?*/
Gdiplus::Image?*image?=?Gdiplus::Image::FromStream(?stream?);

stream->Release();
/*?i?suppose?when?the?reference?count?for?stream?is?0?it?will?
GlobalFree?automatically.?The?Image?maintain?the?object?also.*/
return?image;
}

void?*mi_to_memory(?Gdiplus::Image?*image?void?**outbuf?size_t?*size?)
{
IStream?*stream?=?NULL;
if(?::CreateStreamOnHGlobal(?NULL?TRUE?&stream?)?!=?S_OK?)
{
return?NULL;
}
/*?get?the?jpg?encoder?*/
::CLSID?jpgClsid;
GetEncoderClsid(?L“image/jpeg“?&jpgClsid?);

/*?save?the?image?to?stream?*/
Gdiplus::Status?save_s?=?image->Save(?stream?&jpgClsid?);
if(?save_s?!=?Gdiplus::Ok?)
{
stream->Release();
return?NULL;
}

/*?read?the?stream?to?buffer?*/
if(?!stream_to_mem(?stream?outbuf?size?)?)
{
stream->Release();
return?NULL;
}
return

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-10-09?14:12??Screen_Shot\
?????目錄???????????0??2017-10-09?14:12??Screen_Shot\Debug\
?????目錄???????????0??2017-10-09?14:12??Screen_Shot\ScreenShot\
?????文件?????????897??2017-09-26?22:08??Screen_Shot\ScreenShot.sln
?????文件???????18432??2017-10-09?14:12??Screen_Shot\ScreenShot.suo
?????文件????????3014??2009-05-28?19:47??Screen_Shot\ScreenShot\mem_image.cpp
?????文件?????????645??2009-05-28?19:47??Screen_Shot\ScreenShot\mem_image.h
?????文件????????2366??2017-09-26?22:08??Screen_Shot\ScreenShot\ReadMe.txt
?????文件????????1980??2017-09-26?22:13??Screen_Shot\ScreenShot\resource.h
?????文件???????52660??2017-10-09?13:52??Screen_Shot\ScreenShot\ScreenShot.aps
?????文件????????7186??2017-10-09?14:12??Screen_Shot\ScreenShot\ScreenShot.cpp
?????文件??????????39??2017-09-26?22:08??Screen_Shot\ScreenShot\ScreenShot.h
?????文件???????23558??2009-08-31?02:31??Screen_Shot\ScreenShot\ScreenShot.ico
?????文件????????7496??2017-10-09?13:52??Screen_Shot\ScreenShot\ScreenShot.rc
?????文件????????4607??2017-10-09?11:56??Screen_Shot\ScreenShot\ScreenShot.vcxproj
?????文件????????1804??2017-10-09?11:56??Screen_Shot\ScreenShot\ScreenShot.vcxproj.filters
?????文件?????????143??2017-09-26?22:08??Screen_Shot\ScreenShot\ScreenShot.vcxproj.user
?????文件???????23558??2009-08-31?02:31??Screen_Shot\ScreenShot\small.ico
?????文件?????????215??2017-09-26?22:08??Screen_Shot\ScreenShot\stdafx.cpp
?????文件?????????420??2017-09-26?22:08??Screen_Shot\ScreenShot\stdafx.h
?????文件?????????236??2017-09-26?22:08??Screen_Shot\ScreenShot\targetver.h

評論

共有 條評論