0

Using graphics_capture_frame_buffer a GBitmap is returned. What is the format of this if I wanted to work with it directly. How would I modify a single pixel?

Ajaxharg
  • 2,974
  • 2
  • 18
  • 19

2 Answers2

3

In Pebble 3.0 you can use the gbitmap_* accessors:

When the format is GBitmapFormat8Bit, each pixel is one byte in ARGB (2bits per component).

sarfata
  • 4,625
  • 4
  • 28
  • 36
  • Thank you! Helped me to finally achieve this: http://stackoverflow.com/a/29173750/961695 (though still not sure if this is the best approach) – Yuriy Galanter Mar 20 '15 at 19:13
0

I found this in the isometric example given in the SDK. So it would appear to be one uint8_t per pixel a row at a time holding the ARGB at 2 bits each.

#define GColorFromRGB ((GColor8){ \ .a = 3, \ .r = (uint8_t)(red) >> 6, \ .g = (uint8_t)(green) >> 6, \ .b = (uint8_t)(blue) >> 6, \ })

static void set_pixel(GPoint pixel, GColor color) {
  if(pixel.x >= 0 && pixel.x < 144 && pixel.y >= 0 && pixel.y < 168) {
    memset(&s_fb_data[(pixel.y * s_fb_size.w) + pixel.x], (uint8_t)color.argb, 1);
  }
}
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Ajaxharg
  • 2,974
  • 2
  • 18
  • 19