static int get_image(struct image_info *info, int ds) { unsigned char **p_disp = &disp[ds]; /* short cut */ LodePNG_Decoder *p_decoder = &decoder; info->width = p_decoder->infoPng.width / ds; info->height = p_decoder->infoPng.height / ds; info->data = p_disp; if (*p_disp != NULL) { /* we still have it */ return PLUGIN_OK; } /* assign image buffer */ if (ds > 1) { if (!iv->running_slideshow) { rb->lcd_putsf(0, 3, "resizing %d*%d", info->width, info->height); rb->lcd_update(); } struct bitmap bmp_src, bmp_dst; int size = img_mem(ds); if (disp_buf + size >= p_decoder->buf + p_decoder->buf_size) { /* have to discard the current */ int i; for (i=1; i<=8; i++) disp[i] = NULL; /* invalidate all bitmaps */ /* start again from the beginning of the buffer */ disp_buf = p_decoder->buf + p_decoder->native_img_size; } *p_disp = disp_buf; disp_buf += size; bmp_src.width = p_decoder->infoPng.width; bmp_src.height = p_decoder->infoPng.height; bmp_src.data = p_decoder->buf; bmp_dst.width = info->width; bmp_dst.height = info->height; bmp_dst.data = *p_disp; #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(true); resize_bitmap(&bmp_src, &bmp_dst); rb->cpu_boost(false); #else resize_bitmap(&bmp_src, &bmp_dst); #endif /*HAVE_ADJUSTABLE_CPU_FREQ*/ } else { *p_disp = p_decoder->buf; } return PLUGIN_OK; }
void Fl_Shaped_Window::draw() { if ((lw != w() || lh != h() || changed) && shape_) { // size of window has change since last time lw = w(); lh = h(); Fl_Bitmap* mask = resize_bitmap(shape_, w(), h()); #ifdef _WIN32 HRGN region = bitmap2region(mask); SetWindowRgn(fl_xid(this), region, TRUE); #elif defined(__APPLE__) // not yet implemented for Apple #else Pixmap pmask = XCreateBitmapFromData(fl_display, fl_xid(this), (const char*)mask->data(), mask->width(), mask->height()); hide(); XShapeCombineMask(fl_display, fl_xid(this), ShapeBounding, 0, 0, pmask, ShapeSet); show(); if (pmask != None) XFreePixmap(fl_display, pmask); #endif changed = 0; } Fl_Double_Window::draw(); }
void update_panel_size(window_t *win) { panel_t *panel = &win->panel; bitmap_t *bitmap = &panel->bitmap; bitmap->width = win->w; resize_bitmap(bitmap); panel->ctx.offset_x = 0; panel->ctx.offset_y = win->h-PANEL_HEIGHT; panel->draw.l = 0; panel->draw.t = win->h-PANEL_HEIGHT; panel->draw.r = win->w; panel->draw.b = win->h; panel->ctrl.rc.l = FRAME_WIDTH; panel->ctrl.rc.t = win->h-PANEL_HEIGHT; panel->ctrl.rc.r = win->w-FRAME_WIDTH; panel->ctrl.rc.b = win->h-FRAME_WIDTH; panel->ctrl.w = win->w; panel->ctrl.h = PANEL_HEIGHT; win->client.b = win->h-PANEL_HEIGHT; panel->play_btn->ctrl.rc.l = win->w/2 - 16; panel->play_btn->ctrl.rc.t = panel->ctrl.rc.t+19; panel->play_btn->ctrl.rc.r = panel->play_btn->ctrl.rc.l + panel->play_btn->ctrl.w; panel->play_btn->ctrl.rc.b = panel->play_btn->ctrl.rc.t + panel->play_btn->ctrl.h; panel->stop_btn->ctrl.rc.l = win->w/2 - 44; panel->stop_btn->ctrl.rc.t = panel->ctrl.rc.t+23; panel->stop_btn->ctrl.rc.r = panel->stop_btn->ctrl.rc.l + panel->stop_btn->ctrl.w; panel->stop_btn->ctrl.rc.b = panel->stop_btn->ctrl.rc.t + panel->stop_btn->ctrl.h; panel->sld->ctrl.rc.l = panel->ctrl.rc.l; panel->sld->ctrl.rc.t = panel->ctrl.rc.t+28; panel->sld->ctrl.rc.r = panel->sld->ctrl.rc.l + panel->sld->ctrl.w; panel->sld->ctrl.rc.b = panel->sld->ctrl.rc.t + panel->sld->ctrl.h; panel_update_layout(panel); };
static int get_image(struct image_info *info, int frame, int ds) { unsigned char **p_disp = disp + frame*4 + ds2index(ds); struct gif_decoder *p_decoder = &decoder; info->width = p_decoder->width / ds; info->height = p_decoder->height / ds; info->data = p_disp; if (*p_disp != NULL) { /* we still have it */ return PLUGIN_OK; } /* assign image buffer */ if (ds > 1) { if (!iv->running_slideshow) { rb->lcd_putsf(0, 3, "resizing %d*%d", info->width, info->height); rb->lcd_update(); } struct bitmap bmp_src, bmp_dst; /* size of the scalled image */ int size = img_mem(ds); if (disp_buf + size >= p_decoder->mem + p_decoder->mem_size) { /* have to discard scaled versions */ for (int i=0; i<p_decoder->frames_count; i++) { /* leave unscaled pointer allone, * set rest to NULL */ p_disp = disp + i*4 + 1; memset(p_disp, 0, 3*sizeof(unsigned char *)); } /* start again from the beginning of the buffer */ disp_buf = p_decoder->mem + p_decoder->native_img_size*p_decoder->frames_count + sizeof(unsigned char *)*p_decoder->frames_count*4; } *p_disp = disp_buf; disp_buf += size; bmp_src.width = p_decoder->width; bmp_src.height = p_decoder->height; bmp_src.data = p_decoder->mem + p_decoder->native_img_size*frame; bmp_dst.width = info->width; bmp_dst.height = info->height; bmp_dst.data = *p_disp; #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(true); #endif resize_bitmap(&bmp_src, &bmp_dst); #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); #endif } else { *p_disp = p_decoder->mem + p_decoder->native_img_size*frame; } return PLUGIN_OK; }