diff ostc45_icon.cpp @ 11:6fba58c4964b

Minor changes done by automatic style checker
author Ideenmodellierer
date Mon, 12 Jan 2026 13:57:24 +0000
parents 115cfa4a3239
children
line wrap: on
line diff
--- a/ostc45_icon.cpp	Mon Jan 12 13:55:38 2026 +0000
+++ b/ostc45_icon.cpp	Mon Jan 12 13:57:24 2026 +0000
@@ -1,9 +1,7 @@
 #include "ostc45_icon.h"
 
-
 //OSTC45_Icon::OSTC45_Icon() {}
 
-
 #pragma pack(push, 1)
 struct BMPFileHeader
 {
@@ -17,25 +15,25 @@
 struct BMPInfoHeader
 {
     uint32_t biSize;
-    int32_t  biWidth;
-    int32_t  biHeight;
+    int32_t biWidth;
+    int32_t biHeight;
     uint16_t biPlanes;
     uint16_t biBitCount;
     uint32_t biCompression;
     uint32_t biSizeImage;
-    int32_t  biXPelsPerMeter;
-    int32_t  biYPelsPerMeter;
+    int32_t biXPelsPerMeter;
+    int32_t biYPelsPerMeter;
     uint32_t biClrUsed;
     uint32_t biClrImportant;
 };
 #pragma pack(pop)
 
-BmpToArray::BmpToArray(const QString& filename)
+BmpToArray::BmpToArray(const QString &filename)
 {
     loadBMP(filename);
 }
 
-void BmpToArray::loadBMP(const QString& filename)
+void BmpToArray::loadBMP(const QString &filename)
 {
     QFile file(filename);
     int dstY;
@@ -47,12 +45,12 @@
     if (!file.open(QIODevice::ReadOnly))
         throw std::runtime_error("Cannot open BMP file");
 
-    if (file.read(reinterpret_cast<char*>(&fileHeader),
-                  sizeof(BMPFileHeader)) != sizeof(BMPFileHeader))
+    if (file.read(reinterpret_cast<char *>(&fileHeader), sizeof(BMPFileHeader))
+        != sizeof(BMPFileHeader))
         throw std::runtime_error("Failed to read BMP file header");
 
-    if (file.read(reinterpret_cast<char*>(&infoHeader),
-                  sizeof(BMPInfoHeader)) != sizeof(BMPInfoHeader))
+    if (file.read(reinterpret_cast<char *>(&infoHeader), sizeof(BMPInfoHeader))
+        != sizeof(BMPInfoHeader))
         throw std::runtime_error("Failed to read BMP info header");
 
     if (fileHeader.bfType != 0x4D42)
@@ -63,40 +61,38 @@
     if (infoHeader.biCompression != 0)
         throw std::runtime_error("Compressed BMP not supported");
 
-    if(infoHeader.biWidth > 800)
+    if (infoHeader.biWidth > 800)
         throw std::runtime_error("Only BMP with 800 or less horizontal pixels supported");
 
-    if(infoHeader.biHeight > 480)
+    if (infoHeader.biHeight > 480)
         throw std::runtime_error("Only BMP with 480 or less vertical pixels supported");
 
     // Width / Height
     width = infoHeader.biWidth;
     height = infoHeader.biHeight;
 
-    if ((int32_t)height < 0) {
-        height = -((int32_t)height);
+    if ((int32_t) height < 0) {
+        height = -((int32_t) height);
         topDown = true;
     }
 
     // Palette
     uint32_t colorCount = infoHeader.biClrUsed;
-    if (colorCount == 0) colorCount = 256;
-    if (colorCount > 256) colorCount = 256;
+    if (colorCount == 0)
+        colorCount = 256;
+    if (colorCount > 256)
+        colorCount = 256;
 
     clut.resize(colorCount);
 
     for (uint32_t i = 0; i < colorCount; ++i)
-        file.read(reinterpret_cast<char*>(&clut[i]), 4);
+        file.read(reinterpret_cast<char *>(&clut[i]), 4);
 
     // CLUT in 32-Bit transform 0x00RRGGBB
     clut32.resize(255, 0);
 
-    for (uint32_t i = 0; i < colorCount && i < 255; ++i)
-    {
-        clut32[i] =
-            (clut[i].r << 16) |
-            (clut[i].g << 8) |
-            (clut[i].b);
+    for (uint32_t i = 0; i < colorCount && i < 255; ++i) {
+        clut32[i] = (clut[i].r << 16) | (clut[i].g << 8) | (clut[i].b);
     }
 
     // Pixel-Data
@@ -109,28 +105,20 @@
 
     rowBuffer.resize(rowSize);
 
-    for (int y = 0; y < height; ++y)
-    {
+    for (int y = 0; y < height; ++y) {
         if (file.read(rowBuffer.data(), rowSize) != rowSize)
             throw std::runtime_error("Failed to read BMP pixel row");
 
-        if (topDown)
-        {
+        if (topDown) {
             dstY = height - 1 - y;
-        }
-        else
-        {
+        } else {
             dstY = y;
         }
 
-        for (int x = 0; x < width; ++x)
-        {
-            pixelData[x * height + dstY] =
-                static_cast<uint8_t>(rowBuffer[x]);
+        for (int x = 0; x < width; ++x) {
+            pixelData[x * height + dstY] = static_cast<uint8_t>(rowBuffer[x]);
         }
     }
-
-
 }
 QByteArray BmpToArray::getTransferBytes() const
 {
@@ -139,25 +127,21 @@
     out.reserve(clut32.size() * 4 + pixelData.size());
 
     // CLUT (32 Bit, Little Endian)
-    for (uint32_t color : clut32)
-    {
-        out.append(static_cast<char>( color        & 0xFF));
-        out.append(static_cast<char>((color >> 8)  & 0xFF));
+    for (uint32_t color : clut32) {
+        out.append(static_cast<char>(color & 0xFF));
+        out.append(static_cast<char>((color >> 8) & 0xFF));
         out.append(static_cast<char>((color >> 16) & 0xFF));
         out.append(static_cast<char>((color >> 24) & 0xFF));
     }
 
     // Pixel (8 Bit)
-    out.append(reinterpret_cast<const char*>(pixelData.data()),
-               pixelData.size());
+    out.append(reinterpret_cast<const char *>(pixelData.data()), pixelData.size());
 
     return out;
 }
 
-void BmpToArray::getImageXY(uint32_t* x, uint32_t* y)
+void BmpToArray::getImageXY(uint32_t *x, uint32_t *y)
 {
     *x = width;
     *y = height;
 }
-
-