Projet d'interfaçage avec le joystick réalisé par Ronan CHERIAUX

Dependencies:   BSP_DISCO_F746NG

Revision:
0:1c8761215497
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drawBitmap.cpp	Fri Jun 26 09:17:35 2020 +0000
@@ -0,0 +1,57 @@
+#include "drawBitmap.h"
+#include "stm32746g_discovery_lcd.h"
+
+void drawBitmap(int Xpos, int Ypos, const uint8_t *pbmp, bool transparent)
+{
+    uint32_t index = 0, width = 0, height = 0, bit_pixel = 0;
+    uint32_t *couleur;
+
+    /* Get bitmap data address offset */
+    index = pbmp[10] + (pbmp[11] << 8) + (pbmp[12] << 16)  + (pbmp[13] << 24);
+
+    /* Read bitmap width */
+    width = pbmp[18] + (pbmp[19] << 8) + (pbmp[20] << 16)  + (pbmp[21] << 24);
+
+    /* Read bitmap height */
+    height = pbmp[22] + (pbmp[23] << 8) + (pbmp[24] << 16)  + (pbmp[25] << 24);
+
+    /* Read bit/pixel */
+    bit_pixel = pbmp[28] + (pbmp[29] << 8);
+
+    int xSize = BSP_LCD_GetXSize(), ySize = BSP_LCD_GetYSize();
+    couleur = (uint32_t *)&pbmp[index];
+    int yDebut;
+    if (Ypos+height>=ySize) {
+        yDebut = ySize-1;
+        couleur += width*(Ypos+height-ySize);
+    } else {
+        yDebut = Ypos+height-1;
+    }
+    int yFin = (Ypos<0) ? 0 : Ypos;
+    int xDebut, xDeltaDebut;
+    if (Xpos<0) {
+        xDebut = 0;
+        xDeltaDebut = -Xpos;
+    } else {
+        xDebut = Xpos;
+        xDeltaDebut = 0;
+    }
+    int xFin, xDeltaFin;
+    if (Xpos+width>xSize) {
+        xFin = xSize-1;
+        xDeltaFin = Xpos+width - xSize;
+    } else {
+        xFin = Xpos+width-1;
+        xDeltaFin = 0;
+    }
+    
+    for (int ligne=yDebut; ligne>=yFin; ligne--) {
+        couleur += xDeltaDebut;
+        for (int colonne=xDebut; colonne<=xFin; colonne++) {
+            if (transparent & ((*couleur & 0xFF000000)==0xFF000000)) BSP_LCD_DrawPixel(colonne, ligne, *couleur);
+            couleur++;
+        }
+        couleur += xDeltaFin;
+    }
+}
+