Hello! I'm currently working on a UEFI project and am attempting to display TGA images, but I can't seem to properly display them without it being distorted. I've also been searching high and low for more documentation on this TGA format (not really finding anything helpful) and didn't seem to find an answer to satisfy my needs. I have a simple TGA image with no ID length and no compression so after the 18-byte header I can copy the rest of the data to memory. Accoring to my research these images are usually stored in BGR (and A if you have an alpha channel) so I'd need to swap the order. Does anyone know of some ways I can so this? The target lanugage is C. I've tried doing somthing like reading the data into a temp buffer and swapping (well attempted to rather) the order then storing to the target buffer. Apparently UEFI doesn't like that and crashes so I've been having a hard time learning more about displaying images to a framebuffer.
#How to properly display TGA image to framebuffer UEFI
10 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
RIght now this is what the image looks like after reading it as described above and just displaying it as is
The functions that are called for this:
void TgaDrawImg(EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP, UINT64 x, UINT64 y, UINT64 w, UINT64 h, void *tga_pix_ptr) {
UINT64 *ptr = (UINT64 *)tga_pix_ptr;
GfxDrawImg(GOP, x, y, w, h, ptr);
}
void GfxPutPixel(EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP, UINT64 x, UINT64 y, UINT64 color) {
*(UINT64 *)((UINT64)GOP->Mode->FrameBufferBase + (x * 4) + (y * GOP->Mode->Info->PixelsPerScanLine * 4)) = color;
}
void GfxDrawImg(EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP, UINT64 x, UINT64 y, UINT64 w, UINT64 h, void *pix_ptr) {
UINT64 i, j, l;
UINT64 *ptr = (UINT64 *)pix_ptr;
for (l = j = 0; l < h; l++) {
for (i = 0; i < w; i++, j++) {
GfxPutPixel(GOP, x + i, y + l, ptr[j]);
}
}
}
I've not ever did anything graphics related (as you can see) so I'm hoping somone will be able to point me in the right direction
the framebuffer pixels are usually 32bit bgra where a is reserved not 64bit
you are writing to them as UINT64*
oh you left 💀
You can only close threads you own
why u64 for colour?