Want more features on Pastebin? Sign Up, it's FREE!
Guest

RenderComponent class using GDI+

By: a guest on Jan 6th, 2013  |  syntax: C++  |  size: 1.34 KB  |  views: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #pragma once
  2.  
  3. #include <windows.h>
  4. #include "Library/ObjComponent.h"
  5. #include "Library/Bitmap.h"
  6. #include <gdiplus.h>
  7. //#include <gdiplus/gdiplusgraphics.h>
  8. //#include <Graphics>
  9.  
  10.  
  11. // Component Type Val: 3
  12. class RenderComponent : public ObjComponent
  13. {
  14. public:
  15.   RenderComponent(int parentid, const wchar_t * a_ImagePath); // Create RenderComponent from File
  16.   virtual ~RenderComponent();
  17.  
  18.   virtual void OnUpdate() {};
  19.   virtual void OnMessage(ObjMessage&);
  20.  
  21.   Gdiplus::Image*  Image_Get()         { return m_pImage; };
  22.   Bitmap*          Bitmap_Get()        { return m_pBitmap; };
  23.   int              RenderType_Get()    { return RenderType; };
  24. protected:
  25.   Gdiplus::Image* m_pImage;
  26.   const wchar_t* m_ImagePath;
  27.   int RenderType; // 0 for bitmap, 1 for Gdiplus::Image
  28.   Bitmap* m_pBitmap;
  29. };
  30.  
  31. RenderComponent::RenderComponent(int parentid, const wchar_t * a_ImagePath)
  32.   : ObjComponent(parentid)
  33. {
  34.   RenderType = 1;
  35.   SetType(3);
  36.   m_pImage = new Gdiplus::Image(L"Player.bmp");
  37. }
  38.  
  39. RenderComponent::~RenderComponent()
  40. {
  41.     delete m_pImage;
  42. }
  43.  
  44. void RenderComponent::OnMessage(ObjMessage& m)
  45. {
  46.   if (m.msgType == "Set Rotation") // Will work on once images work
  47.   {
  48.     /*//Gdiplus::Image* pIm = NULL;
  49.     //pIm = new Image("");
  50.     Gdiplus::Graphics *g;
  51.     Gdiplus::Image *i;
  52.     g->FromImage(m_pBitmap);*/
  53.   }
  54. }
clone this paste RAW Paste Data