| Problem 1 |
| Create a Wintempla Window application called PictureView to draw an image using Direct2D (observe that this project is not a DirectX application). After creating the application, open Wintempla and double click the on the GUI editor to select the Paint event. Cree una aplicación de ventana de Wintempla llamada PictureView para dibujar una imagen usando Direct2D (observe que este proyecto no es una aplicación de DirectX). Después de crear la aplicación, abra Wintempla y haga clic doble en el editor de la GUI para seleccionar el evento de Paint. |

| PictureView.h |
| #pragma once //______________________________________ PictureView.h #include "Resource.h" class PictureView: public Win::Window { public: PictureView() { } ~PictureView() { } Direct::Graphics graphics; Direct::Bitmap bitmap; . . . }; |
| PictureView.cpp |
| . . . void PictureView::Window_Open(Win::Event& e) { if (bitmap.Create(graphics, L"pascal.gif", 0) == false) { this->MessageBox(L"Unable to ", L"PictureView", MB_OK | MB_ICONERROR); } } void PictureView::Window_Paint(Win::Event& e) { if (graphics.BeginDraw(hWnd, width, height, 1.0f, 1.0f, 1.0f, 1.0f) == false) return; graphics.SetTransform(D2D1::Matrix3x2F::Identity()); D2D_RECT_F rect = {0.0f, 100.0f, (float)bitmap.GetSize().width, (float)(100+ bitmap.GetSize().height)}; graphics.DrawBitmap(bitmap, rect); graphics.EndDraw(true); } |