+int demo_resizefb(int width, int height, int bpp)
+{
+ int newsz, new_scansz;
+
+ if(!width || !height || !bpp) {
+ free(fb_buf);
+ fb_buf = fb_pixels = 0;
+ fb_size = fb_buf_size = fb_scan_size = 0;
+ fb_width = fb_height = fb_bpp = 0;
+ return 0;
+ }
+
+ new_scansz = ((width + GUARD_XPAD * 2) * bpp + 7) / 8;
+ newsz = (height + GUARD_YPAD * 2) * new_scansz;
+
+ if(!fb_buf || newsz > fb_buf_size) {
+ void *tmp = malloc(newsz);
+ if(!tmp) return -1;
+
+ free(fb_buf);
+ fb_buf = tmp;
+ fb_buf_size = newsz;
+ }
+
+ fb_scan_size = new_scansz;
+ fb_pixels = (uint16_t*)((char*)fb_buf + GUARD_YPAD * fb_scan_size + (GUARD_XPAD * bpp + 7) / 8);
+ fb_width = width;
+ fb_height = height;
+ fb_bpp = bpp;
+ fb_size = fb_scan_size * fb_height;
+
+ fb_aspect = (float)fb_width / (float)fb_height;
+
+ return 0;
+}
+
+