]> git.webhop.me Git - lcd4linux.git/commitdiff
- drv_generic_graphic.c: allow to define vertical area ...
authorsvenhoefer <svenhoefer@svenhoefer.com>
Tue, 3 May 2016 13:21:54 +0000 (15:21 +0200)
committersvenhoefer <svenhoefer@svenhoefer.com>
Tue, 3 May 2016 13:21:54 +0000 (15:21 +0200)
... to center an image.

center 0  ; don't center image
center 1  ; do center image
center 55 ; do center image horizontally and vertically in an area
          ; with a height of 55px

drv_generic_graphic.c

index 396f2294cbc1bec8ff34b828a34fde9342e54271..ecd5e33eca5a7f65441519e04a4eb2e02ffea286 100644 (file)
@@ -578,25 +578,26 @@ int drv_generic_graphic_image_draw(WIDGET * W)
 
        int center = P2N(&Image->center);
        if (center) {
-               int aHight = Image->height;
-               if (Image->oldheight > Image->height) aHight = Image->oldheight;
+               int area_height = (Image->oldheight > Image->height) ? Image->oldheight : Image->height;
+               if (center > area_height)
+                       area_height = center;
                // set layout framebuffer to a fixed size
-               drv_generic_graphic_resizeFB(row + aHight, LCOLS);
+               drv_generic_graphic_resizeFB(row + area_height, LCOLS);
                // flush area
-               drv_generic_graphic_blit(row, 0, aHight, LCOLS);
+               drv_generic_graphic_blit(row, 0, area_height, LCOLS);
                // fill it black or transparent
-               for (y = 0; y < aHight; y++) {
+               for (y = 0; y < area_height; y++) {
                        for (x = 0; x < LCOLS; x++) {
                                int i = (row + y ) * LCOLS + LCOLS + x;
                                drv_generic_graphic_FB[layer][i] = (Driver == "SamsungSPF") ? BG_COL : NO_COL;
                        }
                }
-               // align logo in the area
+               // align image in the area
                if (width < LCOLS)
                        col = (LCOLS / 2) - (width / 2);
                else
                        col = 1;
-               row += (aHight - height) / 2;
+               row += (area_height - height) / 2;
        } else {
                /* maybe grow layout framebuffer */
                drv_generic_graphic_resizeFB(row + height, col + width);