Ответить на сообщение
Вернуться к теме
Вы отвечаете на сообщение:
Автор: heed (19.02.2010 в 20:07) в msdn что-то вроде такого примера по обрезке, вставке и ресайза
#ifndef UNICODE #define UNICODE #endif #include <windows.h> #include <gdiplus.h> using namespace Gdiplus; VOID OnPaint(HDC hdc) { Graphics graphics(hdc); Image image(L"1.jpg"); UINT width = image.GetWidth(); UINT height = image.GetHeight(); // Make the destination rectangle 30 percent wider and // 30 percent taller than the original image.# не знаю как будет в 3 рааза меньше // Put the upper-left corner of the destination // rectangle at (20, 20). Rect destinationRect(20, 20, (int)(0.5 * width), (int)(0.5 * height)); // Draw the image unaltered with its upper-left corner at (10, 10). graphics.DrawImage(&image, 10, 10); // Draw a portion of the image. Scale that portion of the image // so that it fills the destination rectangle graphics.DrawImage( &image, destinationRect, 0, 0, // upper-left corner of source rectangle 0.75 * width, // width of source rectangle 0.75 * height, // height of source rectangle UnitPixel); } LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PSTR, INT iCmdShow) { HWND hWnd; MSG msg; WNDCLASS wndClass; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; // Initialize GDI+. GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = WndProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hInstance = hInstance; wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndClass.lpszMenuName = NULL; wndClass.lpszClassName = TEXT("GettingStarted"); RegisterClass(&wndClass); hWnd = CreateWindow( TEXT("GettingStarted"), // window class name TEXT("Getting Started"), // window caption WS_OVERLAPPEDWINDOW, // window style CW_USEDEFAULT, // initial x position CW_USEDEFAULT, // initial y position CW_USEDEFAULT, // initial x size CW_USEDEFAULT, // initial y size NULL, // parent window handle NULL, // window menu handle hInstance, // program instance handle NULL); // creation parameters ShowWindow(hWnd, iCmdShow); UpdateWindow(hWnd); while(GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } GdiplusShutdown(gdiplusToken); return (int) msg.wParam; } // WinMain LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; switch(message) { case WM_PAINT: hdc = BeginPaint(hWnd, &ps); OnPaint(hdc); EndPaint(hWnd, &ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); } } // WndProc
Ваше имя:
Пароль:
Цитировать Используйте тэги для выделения текста: Код: [code][/code] Жирный: [b][/b] Наклонный: [i][/i] URL: [url][/url]
Сообщение:
Прикрепить: