Subversion Repositories Kolibri OS

Rev

Rev 5296 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include "smalllibc/kosSyst.h"
  2. #include "render.h"
  3.  
  4. CKosRender::CKosRender(int width, int height)
  5. {
  6.         this->width = width;
  7.         this->height = height;
  8.         this->buffer = new RGB[width * height];
  9.         for (int i = 0; i < width * height; i++)
  10.                 this->buffer[i] = 0x000000;
  11. }
  12.  
  13. CKosRender::~CKosRender(void)
  14. {
  15.         //delete this->buffer;
  16. }
  17.  
  18. void CKosRender::Draw(Point position)
  19. {
  20.         kos_PutImage((RGB*)this->buffer, this->width, this->height, position.X, position.Y);
  21. }
  22.  
  23. void CKosRender::RenderImg(RGB *img, Point position, int width, int height)
  24. {
  25.         for (int y = position.Y; y < position.Y + height; y++)
  26.                 for (int x = position.X; x < position.X + width; x++)
  27.                         if (x >= 0 && y >= 0 && x < this->width && y < this->height)
  28.                                 this->buffer[y * this->width + x] = img[(y - position.Y) * width + (x - position.X)];
  29. }
  30.  
  31. int CKosRender::getPixel(int x, int y)
  32. {
  33.         return y * this->width + x;
  34. }
  35.