08-27-2019, 05:11 PM
(This post was last modified: 08-27-2019, 05:13 PM by megamarc.
Edit Reason: Typo
)
Hi Alan,
Welcome here and thanks for your interest!
There isn't any problem with your direct pixel manipulation code. The problem is that any layer requires having a palette assigned. When you load a bitmap with TLN_LoadBitmap() and assign it with TLN_SetLayerBitmap(), it's own palette gets loaded and attached. But you're creating an empty bitmap without a palette. Of course the renderer shouldn't crash, just refuse to draw it. I have to fix this behavior.
To fix your code, you have to manually create and assign a palette with TLN_CreatePalette() and TLN_SetBitmapPalette():
You should get a black window because the default palette is black. To modify it, you can use TLN_SetPaletteColor().
Let me know if it works!
Welcome here and thanks for your interest!
There isn't any problem with your direct pixel manipulation code. The problem is that any layer requires having a palette assigned. When you load a bitmap with TLN_LoadBitmap() and assign it with TLN_SetLayerBitmap(), it's own palette gets loaded and attached. But you're creating an empty bitmap without a palette. Of course the renderer shouldn't crash, just refuse to draw it. I have to fix this behavior.
To fix your code, you have to manually create and assign a palette with TLN_CreatePalette() and TLN_SetBitmapPalette():
Code:
TLN_Bitmap bitmap = TLN_CreateBitmap(400, 240, 8);
TLN_Palette palette = TLN_CreatePalette(256);
TLN_SetBitmapPalette(bitmap, palette);
TLN_SetLayerBitmap(0, bitmap);
You should get a black window because the default palette is black. To modify it, you can use TLN_SetPaletteColor().
Let me know if it works!