6

I'm using Pebble SDK 2 and running into graphics problems.

I'm trying to add a full screen graphic with the dimensions 144 x 168, however, when I do-- the bottom gets clipped.

[picture]

Investigating further- the root layer has the dimensions of 144 x 152 rather than 144 x 168 (Pebble's fullscreen dimensions). I set the window to be full screen, before adding the bitmap and calling window_stack_push, so the status bar should not be an issue (although, the dimensions of the status bar supposedly fit the space I am missing).

Code is below:

void handle_init(void) {
  s_main_window = window_create();
  window_set_fullscreen(s_main_window, true);

  window_set_window_handlers(s_main_window, (WindowHandlers) {
    .load = main_window_load,
    .unload = main_window_unload
  });
  const bool animated = true;
  window_set_click_config_provider(s_main_window, click_config_provider);
  window_stack_push(s_main_window, animated);
}

static void main_window_load(Window *window) {
  // Create GBitmap, then set to created BitmapLayer
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_CHILL_BG5);
  s_background_layer = bitmap_layer_create(GRect(0, 0, 144, 168));
  bitmap_layer_set_bitmap(s_background_layer, s_background_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer));
}

Updated Code:

static void breathe_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);

  // Create GBitmap, then set to created BitmapLayer
  s_background_bitmap_3 = gbitmap_create_with_resource(RESOURCE_ID_CHILL_BG6);
  s_background_layer_3 = bitmap_layer_create(GRect(0, -16, 144, 168));
  bitmap_layer_set_bitmap(s_background_layer_3, s_background_bitmap_3);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(s_background_layer_3));
}

static void breathe_window_unload(Window *window) {
  gbitmap_destroy(s_background_bitmap_3);
  bitmap_layer_destroy(s_background_layer_3);
  animation_unschedule_all();
  window_destroy(s_window_2);
}

static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
  s_window_2 = window_create();
  window_set_window_handlers(s_window_2, (WindowHandlers) {
    .load = breathe_window_load,
    .unload = breathe_window_unload
  });  
  const bool animated = true;
  window_stack_push(s_window_2, animated);

  next_animation();
}
makala.bay
  • 61
  • 2
  • Sounds like a bug. What version of the SDK are you using? What version of the firmware are you testing on? – sarfata Apr 27 '15 at 01:12
  • Also, are you sure that bitmap itself of correct dimensions? – Yuriy Galanter Apr 27 '15 at 19:40
  • Thank you for your reply, @sarfata. I was using SDK Version 2, and testing on Pebble firmware 2.9. Interestingly enough, I was adding an animation to the screen above, and suddenly the bottom sixteen pixels began working properly. While my original problem appears to be solved, I remain perplexed as to how it was fixed.

    I will post updated code above.
    – makala.bay Apr 28 '15 at 21:52
  • Yes, the bitmap was of the dimensions 144 x 168. @YuriyGalanter – makala.bay Apr 28 '15 at 21:54
  • 2
    @makala.bay Could you add your updated code as an answer to this question and mark it as "Answered"? That way the post won't show in "Unanswered questions" :-) – implmentor Aug 18 '15 at 13:04

0 Answers0