diff --git a/ReadMe.txt b/ReadMe.txt index db7aa74..e46533e 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -70,6 +70,7 @@ Version 1.9 (2020-09-XX) - Move the KML folder in the JSON settings embedded in the state file because Windows cannot open the state file with KML url longer than 256 byte. - Prevent to auto save before launching the "Open...", "Save As...", "Load Object...", "Save Object...", etc... - Prevent app not responding (ANR) in NativeLib.buttonUp(). +- In the menu header, switch the pixel format RGB to BGR when an icon of type BMP is defined in the KML script. Version 1.8 (2020-05-24) diff --git a/app/src/main/assets/ReadMe.txt b/app/src/main/assets/ReadMe.txt index f69688b..9334d81 100644 --- a/app/src/main/assets/ReadMe.txt +++ b/app/src/main/assets/ReadMe.txt @@ -70,6 +70,7 @@ Version 1.9 (2020-09-XX) - Move the KML folder in the JSON settings embedded in the state file because Windows cannot open the state file with KML url longer than 256 byte. - Prevent to auto save before launching the "Open...", "Save As...", "Load Object...", "Save Object...", etc... - Prevent app not responding (ANR) in NativeLib.buttonUp(). +- In the menu header, switch the pixel format RGB to BGR when an icon of type BMP is defined in the KML script. Version 1.8 (2020-05-24) diff --git a/app/src/main/cpp/win32-layer.c b/app/src/main/cpp/win32-layer.c index e81161d..64ff4dc 100644 --- a/app/src/main/cpp/win32-layer.c +++ b/app/src/main/cpp/win32-layer.c @@ -885,11 +885,19 @@ static HBITMAP DecodeBMPIcon(LPBYTE imageBuffer, size_t imageSize) { // Inverse the height BYTE *source = imageBuffer + dwFileSize - stride; BYTE *destination = hBitmap->bitmapBits; - for (int i = 0; i < height; ++i) { - memcpy(destination, source, stride); - source -= stride; - destination += stride; - } + DWORD width = pBmi->bmiHeader.biWidth; + for (unsigned int y = 0; y < height; ++y) { + for (unsigned int x = 0; x < width; ++x) { + BYTE * sourcePixel = source + (x << 2); + BYTE * destinationPixel = destination + (x << 2); + destinationPixel[0] = sourcePixel[2]; + destinationPixel[1] = sourcePixel[1]; + destinationPixel[2] = sourcePixel[0]; + destinationPixel[3] = sourcePixel[3]; + } + source -= stride; + destination += stride; + } } // Only support 32bits RGBA BMP for now. return hBitmap; @@ -911,14 +919,14 @@ static HBITMAP DecodePNGIcon(LPBYTE imageBuffer, size_t imageSize) { bmi.bmiHeader.biCompression = BI_RGB; // bitmap dimensions - LONG lBytesPerLine = (((bmi.bmiHeader.biWidth * bmi.bmiHeader.biBitCount) + 31) / 32 * 4); - bmi.bmiHeader.biSizeImage = (DWORD) (lBytesPerLine * bmi.bmiHeader.biHeight); + LONG stride = (((bmi.bmiHeader.biWidth * bmi.bmiHeader.biBitCount) + 31) / 32 * 4); + bmi.bmiHeader.biSizeImage = (DWORD) (stride * bmi.bmiHeader.biHeight); // allocate buffer for pixels LPBYTE pbyPixels; // BMP buffer hBitmap = CreateDIBSection(hWindowDC, &bmi, DIB_RGB_COLORS, (VOID **)&pbyPixels, NULL, 0); if (hBitmap) - memcpy(pbyPixels, pbyImage, bmi.bmiHeader.biSizeImage); + memcpy(pbyPixels, pbyImage, bmi.bmiHeader.biSizeImage); } if (pbyImage != NULL) @@ -3116,4 +3124,3 @@ int win32_select(int __fd_count, fd_set* __read_fds, fd_set* __write_fds, fd_set } return select(__fd_count, __read_fds, __write_fds, __exception_fds, __timeout); } - \ No newline at end of file diff --git a/app/src/main/java/org/emulator/calculator/MainScreenView.java b/app/src/main/java/org/emulator/calculator/MainScreenView.java index dd530c8..5ee93f2 100644 --- a/app/src/main/java/org/emulator/calculator/MainScreenView.java +++ b/app/src/main/java/org/emulator/calculator/MainScreenView.java @@ -215,8 +215,10 @@ public class MainScreenView extends PanAndScaleView { break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: + float pointerX = event.getX(actionIndex); + float pointerY = event.getY(actionIndex); post(() -> { - NativeLib.buttonUp((int) ((event.getX(actionIndex) - viewPanOffsetX) / viewScaleFactorX), (int) ((event.getY(actionIndex) - viewPanOffsetY) / viewScaleFactorY)); + NativeLib.buttonUp((int) ((pointerX - viewPanOffsetX) / viewScaleFactorX), (int) ((pointerY - viewPanOffsetY) / viewScaleFactorY)); }); currentButtonTouched.remove(actionIndex); preventToScroll = currentButtonTouched.size() > 0;