My question is quite simple - is there a way to paste a .bmp from the project directory into the calculator's VRAM? I'm not too bothered about size restrictions, I just want to know if it can be done.
It should be possible to build a .bmp file where you can just copy the image data to VRAM, but it'll require some careful construction to get the right format.

The constraints are:
  • 384*216 resolution
  • 16 bits per pixel, RGB565
  • Row-major layout, topmost row first
  • Stride equal to image width (no row padding)

It turns out that all of these can be satisfied with a carefully crafted .bmp file. The resolution is easy enough, since no kind of .bmp header supports less than 64k pixels in either dimension. The stride is also fine, since 384 pixels * 2 bytes per pixel = 768 bytes, which evenly divides by 4.

BMPs always use row-major layout, but are generally stored with the bottom-most row first. Wikipedia says that as long as the image header uses one of the formats with signed dimensions, the row ordering will be reversed if image height is negative. So we'll do that.

The remaining part is the trickiest part: getting the right pixel format. The lowest header version that seems officially documented and supports bitfield compression is BITMAPV4HEADER, so referring to that structure you'd need a bitmap header like this (written as C code for convenience):

Code:
{
  .bV4Size = sizeof(BITMAPV4HEADER),
  .bV4Width = 384,
  .bV4Height = -216,
  .bV4Planes = 1,  // Always 1
  .bV4BitCount = 16,
  .bV4V4Compression = BI_BITFIELDS,  // Bitmasks specify channels in each pixel
  .bV4XPelsPerMeter = 1,  // Pixel density is unimportant
  .bV4YPelsPerMeter = 1,
  .bV4ClrUsed = 0,  // No color table
  .bV4RedMask = 0xF800,
  .bV4GreenMask = 0x07E0,
  .bV4BlueMask = 0x001F,
}


(I haven't actually tried to do this, so there might be subtleties that make it more difficult than I think, or it might just not work for some reason.)
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement