- Jan 22 Wed 2014 10:41
【C++ 隨手小記】MFC 視窗背景色
- Jan 15 Wed 2014 16:41
【C++ 隨手小記】MFC 重構元件
1. 在Create() 時的Style要加上 BS_OWNERDRAW
2. 在Class中加上 virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
- Jan 02 Thu 2014 14:59
【C++ 隨手小記】raw socket in win7
- Sep 13 Fri 2013 16:16
【C++ 懶人用法】取得JPEG的RGB
#include <windows.h> #pragma comment( lib, "gdiplus.lib" ) #include <gdiplus.h> using namespace Gdiplus; int GetEncoderClsid(const WCHAR* format, CLSID* pClsid) { UINT num = 0; // number of image encoders UINT size = 0; // size of the image encoder array in bytes ImageCodecInfo* pImageCodecInfo = NULL; GetImageEncodersSize(&num, &size); if(size == 0) return -1; // Failure pImageCodecInfo = (ImageCodecInfo*)(malloc(size)); if(pImageCodecInfo == NULL) return -1; // Failure GetImageEncoders(num, size, pImageCodecInfo); for(UINT j = 0; j < num; ++j) { if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 ) { *pClsid = pImageCodecInfo[j].Clsid; free(pImageCodecInfo); return j; // Success } } free(pImageCodecInfo); return -1; // Failure } void Filter( Bitmap* src, Bitmap* dst ) { int w, h; w = src->GetWidth(); h = src->GetHeight(); for( int y=0; y<h; y++ ) { for( int x=0; x<w; x++ ) { Color c; c = src->GetPixel( x, y ); // do something interesting here! dst->SetPixel( x, y, c ); } } } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR sCmdLine, int nCmdShow ) { GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); Bitmap* pBitmapIn = new Bitmap( L"input.jpg" ); Bitmap* pBitmapOut = new Bitmap( pBitmapIn->GetWidth(), pBitmapIn->GetHeight(), PixelFormat32bppRGB ); Filter( pBitmapIn, pBitmapOut ); CLSID encoderClsid; GetEncoderClsid(L"image/jpg", &encoderClsid); pBitmapOut->Save( L"output.jpg", &encoderClsid, 0 ); GdiplusShutdown(gdiplusToken); return 0; }
- Sep 13 Fri 2013 09:27
【C++ 懶人用法】MFC 貼 JPEG 方法 (網路上找到的)
- Sep 19 Wed 2012 16:39
c++ socket - Broadcast sendto + recvfrom
- May 15 Tue 2012 08:27
MFC Webbrowser on dialog
- Apr 11 Wed 2012 00:56
【C++ 懶人用法】製作及使用 Dll
- Feb 29 Wed 2012 17:05
【Android 懶人用法】Sleep 用法
- Feb 27 Mon 2012 15:19
【Android 懶人用法】將Integer值放上EditText