Broken 16 bits per pixel bitmaps

This commit is contained in:
UnknownShadow200 2024-06-28 08:12:46 +10:00
parent 3b0f54bc6a
commit cadf185cee
27 changed files with 84 additions and 50 deletions

View File

@ -35,12 +35,12 @@ void Bitmap_UNSAFE_CopyBlock(int srcX, int srcY, int dstX, int dstY,
void Bitmap_Allocate(struct Bitmap* bmp, int width, int height) { void Bitmap_Allocate(struct Bitmap* bmp, int width, int height) {
bmp->width = width; bmp->height = height; bmp->width = width; bmp->height = height;
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "bitmap data"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "bitmap data");
} }
void Bitmap_TryAllocate(struct Bitmap* bmp, int width, int height) { void Bitmap_TryAllocate(struct Bitmap* bmp, int width, int height) {
bmp->width = width; bmp->height = height; bmp->width = width; bmp->height = height;
bmp->scan0 = (BitmapCol*)Mem_TryAlloc(width * height, 4); bmp->scan0 = (BitmapCol*)Mem_TryAlloc(width * height, BITMAPCOLOR_SIZE);
} }
void Bitmap_Scale(struct Bitmap* dst, struct Bitmap* src, void Bitmap_Scale(struct Bitmap* dst, struct Bitmap* src,
@ -409,9 +409,9 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {
for (i = 0; i < dataSize; i += 3) { for (i = 0; i < dataSize; i += 3) {
palette[i / 3] &= BITMAPCOLOR_A_MASK; /* set RGB to 0 */ palette[i / 3] &= BITMAPCOLOR_A_MASK; /* set RGB to 0 */
palette[i / 3] |= buffer[i ] << BITMAPCOLOR_R_SHIFT; palette[i / 3] |= BitmapColor_R_Bits(buffer[i ]);
palette[i / 3] |= buffer[i + 1] << BITMAPCOLOR_G_SHIFT; palette[i / 3] |= BitmapColor_G_Bits(buffer[i + 1]);
palette[i / 3] |= buffer[i + 2] << BITMAPCOLOR_B_SHIFT; palette[i / 3] |= BitmapColor_B_Bits(buffer[i + 2]);
} }
} break; } break;
@ -434,7 +434,7 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {
/* set alpha component of palette */ /* set alpha component of palette */
for (i = 0; i < dataSize; i++) { for (i = 0; i < dataSize; i++) {
palette[i] &= BITMAPCOLOR_RGB_MASK; /* set A to 0 */ palette[i] &= BITMAPCOLOR_RGB_MASK; /* set A to 0 */
palette[i] |= buffer[i] << BITMAPCOLOR_A_SHIFT; palette[i] |= BitmapColor_A_Bits(buffer[i]);
} }
} else if (colorspace == PNG_COLOR_RGB) { } else if (colorspace == PNG_COLOR_RGB) {
if (dataSize != 6) return PNG_ERR_TRANS_COUNT; if (dataSize != 6) return PNG_ERR_TRANS_COUNT;

View File

@ -6,8 +6,15 @@
*/ */
struct Stream; struct Stream;
/* Represents a packed 32 bit RGBA colour, suitable for native graphics API texture pixels. */ /* Represents a packed RGBA colour, suitable for 3D graphics API textures and 2D window framebuffers. */
typedef cc_uint32 BitmapCol; #ifndef BITMAP_16BPP
typedef cc_uint32 BitmapCol;
#define BITMAPCOLOR_SIZE 4
#else
typedef cc_uint16 BitmapCol;
#define BITMAPCOLOR_SIZE 2
#endif
#if defined CC_BUILD_WEB || defined CC_BUILD_ANDROID || defined CC_BUILD_PSP || defined CC_BUILD_PSVITA || defined CC_BUILD_PS2 #if defined CC_BUILD_WEB || defined CC_BUILD_ANDROID || defined CC_BUILD_PSP || defined CC_BUILD_PSVITA || defined CC_BUILD_PS2
#define BITMAPCOLOR_R_SHIFT 0 #define BITMAPCOLOR_R_SHIFT 0
#define BITMAPCOLOR_G_SHIFT 8 #define BITMAPCOLOR_G_SHIFT 8
@ -18,6 +25,11 @@ typedef cc_uint32 BitmapCol;
#define BITMAPCOLOR_G_SHIFT 16 #define BITMAPCOLOR_G_SHIFT 16
#define BITMAPCOLOR_B_SHIFT 8 #define BITMAPCOLOR_B_SHIFT 8
#define BITMAPCOLOR_A_SHIFT 0 #define BITMAPCOLOR_A_SHIFT 0
#elif defined BITMAP_16BPP
#define BITMAPCOLOR_B_SHIFT 0
#define BITMAPCOLOR_G_SHIFT 5
#define BITMAPCOLOR_R_SHIFT 10
#define BITMAPCOLOR_A_SHIFT 15
#else #else
#define BITMAPCOLOR_B_SHIFT 0 #define BITMAPCOLOR_B_SHIFT 0
#define BITMAPCOLOR_G_SHIFT 8 #define BITMAPCOLOR_G_SHIFT 8
@ -25,21 +37,43 @@ typedef cc_uint32 BitmapCol;
#define BITMAPCOLOR_A_SHIFT 24 #define BITMAPCOLOR_A_SHIFT 24
#endif #endif
#define BITMAPCOLOR_R_MASK (0xFFU << BITMAPCOLOR_R_SHIFT) #ifndef BITMAP_16BPP
#define BITMAPCOLOR_G_MASK (0xFFU << BITMAPCOLOR_G_SHIFT) /* Masks a packed color to the selected component */
#define BITMAPCOLOR_B_MASK (0xFFU << BITMAPCOLOR_B_SHIFT) #define BITMAPCOLOR_R_MASK (0xFFU << BITMAPCOLOR_R_SHIFT)
#define BITMAPCOLOR_A_MASK (0xFFU << BITMAPCOLOR_A_SHIFT) #define BITMAPCOLOR_G_MASK (0xFFU << BITMAPCOLOR_G_SHIFT)
#define BITMAPCOLOR_B_MASK (0xFFU << BITMAPCOLOR_B_SHIFT)
/* Extracts just the R/G/B/A component from a bitmap color */ #define BITMAPCOLOR_A_MASK (0xFFU << BITMAPCOLOR_A_SHIFT)
#define BitmapCol_R(color) ((cc_uint8)(color >> BITMAPCOLOR_R_SHIFT))
#define BitmapCol_G(color) ((cc_uint8)(color >> BITMAPCOLOR_G_SHIFT)) /* Extracts just the R/G/B/A component from a bitmap color */
#define BitmapCol_B(color) ((cc_uint8)(color >> BITMAPCOLOR_B_SHIFT)) #define BitmapCol_R(color) ((cc_uint8)(color >> BITMAPCOLOR_R_SHIFT))
#define BitmapCol_A(color) ((cc_uint8)(color >> BITMAPCOLOR_A_SHIFT)) #define BitmapCol_G(color) ((cc_uint8)(color >> BITMAPCOLOR_G_SHIFT))
#define BitmapCol_B(color) ((cc_uint8)(color >> BITMAPCOLOR_B_SHIFT))
#define BitmapColor_R_Bits(color) ((cc_uint8)(color) << BITMAPCOLOR_R_SHIFT) #define BitmapCol_A(color) ((cc_uint8)(color >> BITMAPCOLOR_A_SHIFT))
#define BitmapColor_G_Bits(color) ((cc_uint8)(color) << BITMAPCOLOR_G_SHIFT)
#define BitmapColor_B_Bits(color) ((cc_uint8)(color) << BITMAPCOLOR_B_SHIFT) /* Converts input value into a packed color component */
#define BitmapColor_A_Bits(color) ((cc_uint8)(color) << BITMAPCOLOR_A_SHIFT) #define BitmapColor_R_Bits(value) ((cc_uint8)(value) << BITMAPCOLOR_R_SHIFT)
#define BitmapColor_G_Bits(value) ((cc_uint8)(value) << BITMAPCOLOR_G_SHIFT)
#define BitmapColor_B_Bits(value) ((cc_uint8)(value) << BITMAPCOLOR_B_SHIFT)
#define BitmapColor_A_Bits(value) ((cc_uint8)(value) << BITMAPCOLOR_A_SHIFT)
#else
/* Masks a packed color to the selected component */
#define BITMAPCOLOR_R_MASK (0x3FU << BITMAPCOLOR_R_SHIFT)
#define BITMAPCOLOR_G_MASK (0x3FU << BITMAPCOLOR_G_SHIFT)
#define BITMAPCOLOR_B_MASK (0x3FU << BITMAPCOLOR_B_SHIFT)
#define BITMAPCOLOR_A_MASK (0x01U << BITMAPCOLOR_A_SHIFT)
/* Extracts just the R/G/B/A component from a bitmap color */
#define BitmapCol_R(color) (((cc_uint8)(color >> BITMAPCOLOR_R_SHIFT) & 0x3F) << 3)
#define BitmapCol_G(color) (((cc_uint8)(color >> BITMAPCOLOR_G_SHIFT) & 0x3F) << 3)
#define BitmapCol_B(color) (((cc_uint8)(color >> BITMAPCOLOR_B_SHIFT) & 0x3F) << 3)
#define BitmapCol_A(color) (((cc_uint8)(color >> BITMAPCOLOR_A_SHIFT) & 0x01) << 7)
/* Converts input value into a packed color component */
#define BitmapColor_R_Bits(value) (((cc_uint8)(value) >> 3) << BITMAPCOLOR_R_SHIFT)
#define BitmapColor_G_Bits(value) (((cc_uint8)(value) >> 3) << BITMAPCOLOR_G_SHIFT)
#define BitmapColor_B_Bits(value) (((cc_uint8)(value) >> 3) << BITMAPCOLOR_B_SHIFT)
#define BitmapColor_A_Bits(value) (((cc_uint8)(value) >> 7) << BITMAPCOLOR_A_SHIFT)
#endif
#define BitmapCol_Make(r, g, b, a) (BitmapColor_R_Bits(r) | BitmapColor_G_Bits(g) | BitmapColor_B_Bits(b) | BitmapColor_A_Bits(a)) #define BitmapCol_Make(r, g, b, a) (BitmapColor_R_Bits(r) | BitmapColor_G_Bits(g) | BitmapColor_B_Bits(b) | BitmapColor_A_Bits(a))
#define BitmapColor_RGB(r, g, b) (BitmapColor_R_Bits(r) | BitmapColor_G_Bits(g) | BitmapColor_B_Bits(b) | BITMAPCOLOR_A_MASK) #define BitmapColor_RGB(r, g, b) (BitmapColor_R_Bits(r) | BitmapColor_G_Bits(g) | BitmapColor_B_Bits(b) | BITMAPCOLOR_A_MASK)

View File

@ -163,7 +163,7 @@ void Context2D_Alloc(struct Context2D* ctx, int width, int height) {
ctx->bmp.width = width; ctx->bmp.width = width;
ctx->bmp.height = height; ctx->bmp.height = height;
ctx->bmp.scan0 = (BitmapCol*)Mem_AllocCleared(width * height, 4, "bitmap data"); ctx->bmp.scan0 = (BitmapCol*)Mem_AllocCleared(width * height, BITMAPCOLOR_SIZE, "bitmap data");
} }
void Context2D_Wrap(struct Context2D* ctx, struct Bitmap* bmp) { void Context2D_Wrap(struct Context2D* ctx, struct Bitmap* bmp) {

View File

@ -93,7 +93,7 @@ cc_bool Drawer2D_IsWhiteColor(char c);
cc_bool Drawer2D_UNSAFE_NextPart(cc_string* left, cc_string* part, char* colorCode); cc_bool Drawer2D_UNSAFE_NextPart(cc_string* left, cc_string* part, char* colorCode);
/* Divides R/G/B by 4 */ /* Divides R/G/B by 4 */
#define SHADOW_MASK ((0x3F << BITMAPCOLOR_R_SHIFT) | (0x3F << BITMAPCOLOR_G_SHIFT) | (0x3F << BITMAPCOLOR_B_SHIFT)) #define SHADOW_MASK (BitmapColor_R_Bits(0x3F) | BitmapColor_G_Bits(0x3F) | BitmapColor_B_Bits(0x3F))
static CC_INLINE BitmapCol GetShadowColor(BitmapCol c) { static CC_INLINE BitmapCol GetShadowColor(BitmapCol c) {
if (Drawer2D.BlackTextShadows) return BITMAPCOLOR_BLACK; if (Drawer2D.BlackTextShadows) return BITMAPCOLOR_BLACK;

View File

@ -178,7 +178,7 @@ static void D3D11_DoMipmaps(ID3D11Resource* texture, int x, int y, struct Bitmap
if (width > 1) width /= 2; if (width > 1) width /= 2;
if (height > 1) height /= 2; if (height > 1) height /= 2;
cur = (BitmapCol*)Mem_Alloc(width * height, 4, "mipmaps"); cur = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "mipmaps");
GenMipmaps(width, height, cur, prev, rowWidth); GenMipmaps(width, height, cur, prev, rowWidth);
D3D11_BOX box; D3D11_BOX box;

View File

@ -287,7 +287,7 @@ static void D3D9_DoMipmaps(IDirect3DTexture9* texture, int x, int y, struct Bitm
if (width > 1) width /= 2; if (width > 1) width /= 2;
if (height > 1) height /= 2; if (height > 1) height /= 2;
cur = (BitmapCol*)Mem_Alloc(width * height, 4, "mipmaps"); cur = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "mipmaps");
GenMipmaps(width, height, cur, prev, rowWidth); GenMipmaps(width, height, cur, prev, rowWidth);
Bitmap_Init(mipmap, width, height, cur); Bitmap_Init(mipmap, width, height, cur);

View File

@ -98,7 +98,7 @@ static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) { void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
CCTexture* tex = (CCTexture*)texId; CCTexture* tex = (CCTexture*)texId;
cc_uint32* dst = (tex->pixels + x) + y * tex->width; BitmapCol* dst = (tex->pixels + x) + y * tex->width;
CopyTextureData(dst, tex->width * 4, part, rowWidth << 2); CopyTextureData(dst, tex->width * 4, part, rowWidth << 2);
} }

View File

@ -189,7 +189,7 @@ void Gamepads_Process(float delta) {
*------------------------------------------------------Framebuffer--------------------------------------------------------* *------------------------------------------------------Framebuffer--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -481,7 +481,7 @@ cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* save_args) {
} }
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -287,7 +287,7 @@ void Gamepads_Process(float delta) {
*------------------------------------------------------Framebuffer--------------------------------------------------------* *------------------------------------------------------Framebuffer--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -452,7 +452,7 @@ void Gamepads_Process(float delta) {
*------------------------------------------------------Framebuffer--------------------------------------------------------* *------------------------------------------------------Framebuffer--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -439,7 +439,7 @@ static PixMapHandle fb_pixmap;
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
if (!useGWorld) { if (!useGWorld) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
return; return;

View File

@ -152,7 +152,7 @@ void Gamepads_Process(float delta) {
*------------------------------------------------------Framebuffer--------------------------------------------------------* *------------------------------------------------------Framebuffer--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -257,7 +257,7 @@ void Gamepads_Process(float delta) {
*------------------------------------------------------Framebuffer--------------------------------------------------------* *------------------------------------------------------Framebuffer--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -163,7 +163,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
PutDispEnv(&disp); PutDispEnv(&disp);
SetDispMask(1); SetDispMask(1);
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;

View File

@ -260,7 +260,7 @@ void Gamepads_Process(float delta) {
*------------------------------------------------------Framebuffer--------------------------------------------------------* *------------------------------------------------------Framebuffer--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;

View File

@ -136,7 +136,7 @@ void Gamepads_Process(float delta) {
*------------------------------------------------------Framebuffer--------------------------------------------------------* *------------------------------------------------------Framebuffer--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -194,7 +194,7 @@ void Gamepads_Process(float delta) {
*#########################################################################################################################*/ *#########################################################################################################################*/
static struct Bitmap fb_bmp; static struct Bitmap fb_bmp;
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
fb_bmp = *bmp; fb_bmp = *bmp;

View File

@ -198,7 +198,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
framebufferCreate(&fb, nwindowGetDefault(), DisplayInfo.Width, DisplayInfo.Height, PIXEL_FORMAT_BGRA_8888, 2); framebufferCreate(&fb, nwindowGetDefault(), DisplayInfo.Width, DisplayInfo.Height, PIXEL_FORMAT_BGRA_8888, 2);
framebufferMakeLinear(&fb); framebufferMakeLinear(&fb);
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -529,7 +529,7 @@ cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -374,7 +374,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
GX2InitTextureRegs(&fb); GX2InitTextureRegs(&fb);
fb.surface.image = MEMAllocFromDefaultHeapEx(fb.surface.imageSize, fb.surface.alignment); fb.surface.image = MEMAllocFromDefaultHeapEx(fb.surface.imageSize, fb.surface.alignment);
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -1133,7 +1133,7 @@ static int fb_fast;
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
if (!fb_gc) fb_gc = XCreateGC(win_display, win_handle, 0, NULL); if (!fb_gc) fb_gc = XCreateGC(win_display, win_handle, 0, NULL);
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
@ -1141,7 +1141,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
/* Easy for 24/32 bit case, but much trickier with other depths */ /* Easy for 24/32 bit case, but much trickier with other depths */
/* (have to do a manual and slow second blit for other depths) */ /* (have to do a manual and slow second blit for other depths) */
fb_fast = win_visual.depth == 24 || win_visual.depth == 32; fb_fast = win_visual.depth == 24 || win_visual.depth == 32;
fb_data = fb_fast ? bmp->scan0 : Mem_Alloc(width * height, 4, "window blit"); fb_data = fb_fast ? bmp->scan0 : Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window blit");
fb_image = XCreateImage(win_display, win_visual.visual, fb_image = XCreateImage(win_display, win_visual.visual,
win_visual.depth, ZPixmap, 0, fb_data, win_visual.depth, ZPixmap, 0, fb_data,

View File

@ -193,7 +193,7 @@ void Gamepads_Process(float delta) {
*------------------------------------------------------Framebuffer--------------------------------------------------------* *------------------------------------------------------Framebuffer--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -147,7 +147,7 @@ void Gamepads_Process(float delta) {
*------------------------------------------------------Framebuffer--------------------------------------------------------* *------------------------------------------------------Framebuffer--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
} }

View File

@ -702,7 +702,7 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
*#########################################################################################################################*/ *#########################################################################################################################*/
static struct Bitmap fb_bmp; static struct Bitmap fb_bmp;
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
fb_bmp = *bmp; fb_bmp = *bmp;

View File

@ -79,7 +79,7 @@ static void Gfx_DoMipmaps(int x, int y, struct Bitmap* bmp, int rowWidth, cc_boo
if (width > 1) width /= 2; if (width > 1) width /= 2;
if (height > 1) height /= 2; if (height > 1) height /= 2;
cur = (BitmapCol*)Mem_Alloc(width * height, 4, "mipmaps"); cur = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "mipmaps");
GenMipmaps(width, height, cur, prev, rowWidth); GenMipmaps(width, height, cur, prev, rowWidth);
if (partial) { if (partial) {
@ -244,7 +244,7 @@ cc_result Gfx_TakeScreenshot(struct Stream* output) {
bmp.width = vp[2]; bmp.width = vp[2];
bmp.height = vp[3]; bmp.height = vp[3];
bmp.scan0 = (BitmapCol*)Mem_TryAlloc(bmp.width * bmp.height, 4); bmp.scan0 = (BitmapCol*)Mem_TryAlloc(bmp.width * bmp.height, BITMAPCOLOR_SIZE);
if (!bmp.scan0) return ERR_OUT_OF_MEMORY; if (!bmp.scan0) return ERR_OUT_OF_MEMORY;
glReadPixels(0, 0, bmp.width, bmp.height, PIXEL_FORMAT, TRANSFER_FORMAT, bmp.scan0); glReadPixels(0, 0, bmp.width, bmp.height, PIXEL_FORMAT, TRANSFER_FORMAT, bmp.scan0);

View File

@ -1401,7 +1401,7 @@ void LBackend_Redraw(void) {
struct Bitmap bmp; struct Bitmap bmp;
bmp.width = max(Window_Main.Width, 1); bmp.width = max(Window_Main.Width, 1);
bmp.height = max(Window_Main.Height, 1); bmp.height = max(Window_Main.Height, 1);
bmp.scan0 = (BitmapCol*)Mem_Alloc(bmp.width * bmp.height, 4, "window pixels"); bmp.scan0 = (BitmapCol*)Mem_Alloc(bmp.width * bmp.height, BITMAPCOLOR_SIZE, "window pixels");
Context2D_Wrap(&ctx, &bmp); Context2D_Wrap(&ctx, &bmp);
win_ctx = CGBitmapContextCreate(bmp.scan0, bmp.width, bmp.height, 8, bmp.width * 4, win_ctx = CGBitmapContextCreate(bmp.scan0, bmp.width, bmp.height, 8, bmp.width * 4,