Image and Direct2D


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. For this exercise, you need an uncompressed 24 bits (or 32 bits) bitmap. You can also use a GIF.
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. Para este ejercicio, usted necesita un bitmap sin compresión de 24 o 32 bits. Usted también puede usar un GIF.

PictureViewRun

PictureView.h
#pragma once //______________________________________ PictureView.h
#include "Resource.h"
class PictureView: public Win::Window
{
public:
     PictureView()
     {
     }
     ~PictureView()
     {
     }
     CG::DIBitmap diBitmap;
     Direct::Graphics graphics;
     Direct::Bitmap bitmap;
     . . .
};


PictureView.cpp
. . .
void PictureView::Window_Open(Win::Event& e)
{
     const wchar_t* error = diBitmap.Load(L"pascal.gif");
     if (error != nullptr)
     {
          this->MessageBox(error, L"PictureView", MB_OK | MB_ICONERROR);
     }
     bitmap.Create(graphics, diBitmap);
}

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)diBitmap.GetWidth(), (float)(100+diBitmap.GetHeight())};
     graphics.DrawBitmap(bitmap, rect);
     graphics.EndDraw(true);
}



© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home