Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Direct Pixel Manipulation (looking for an example of TLN_GetBitmapPtr)
#1
Hey everyone,

I've just started to learn how to use Tilengine, and I was checking ou how to do direct pixel manipulation with the TLN_GetBitmapPtr function, but when changed the value of the pointer the program segfaulted (obviously). And since I could not find any examples of that function (well, not easily at least) I decided to ask some one over here to see if I can get some help.

This is my noob code:

Code:
#include <stdio.h>
#include <stdlib.h>
#include "Tilengine.h"

int main (int argc, char* argv[])
{
   TLN_Init(400, 240, 1, 0, 0);

   TLN_SetBGColor(0, 36, 96);

   TLN_CreateWindow(NULL, 0);

   TLN_Bitmap bitmap = TLN_CreateBitmap(400, 240, 8);

   TLN_SetLayerBitmap(0, bitmap);

   int frame = 0;
   while(TLN_ProcessWindow())
   {
       TLN_DrawFrame(frame);

       for (int x = 0; x < 400; x++)
       {
           for (int y = 0; y < 240; y++)
           {
               uint8_t *pixel = TLN_GetBitmapPtr(bitmap, x, y);
               *pixel = (uint8_t)0xff;
           }
       }

       frame++;
   }

   TLN_DeleteBitmap(bitmap);
   TLN_DeleteWindow();
   TLN_Deinit();
   return 0;
}

Already thanking the support,

Alan.
Reply


Messages In This Thread
Direct Pixel Manipulation (looking for an example of TLN_GetBitmapPtr) - by alanhdiniz - 08-27-2019, 03:15 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)