- In the menu header, switch the pixel format RGB to BGR when an icon of type BMP is defined in the KML script.

This commit is contained in:
dgis 2020-09-05 11:09:00 +02:00
parent 161b1207c9
commit 897c3d41c9
4 changed files with 21 additions and 10 deletions

View file

@ -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. - 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 to auto save before launching the "Open...", "Save As...", "Load Object...", "Save Object...", etc...
- Prevent app not responding (ANR) in NativeLib.buttonUp(). - 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) Version 1.8 (2020-05-24)

View file

@ -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. - 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 to auto save before launching the "Open...", "Save As...", "Load Object...", "Save Object...", etc...
- Prevent app not responding (ANR) in NativeLib.buttonUp(). - 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) Version 1.8 (2020-05-24)

View file

@ -885,11 +885,19 @@ static HBITMAP DecodeBMPIcon(LPBYTE imageBuffer, size_t imageSize) {
// Inverse the height // Inverse the height
BYTE *source = imageBuffer + dwFileSize - stride; BYTE *source = imageBuffer + dwFileSize - stride;
BYTE *destination = hBitmap->bitmapBits; BYTE *destination = hBitmap->bitmapBits;
for (int i = 0; i < height; ++i) { DWORD width = pBmi->bmiHeader.biWidth;
memcpy(destination, source, stride); for (unsigned int y = 0; y < height; ++y) {
source -= stride; for (unsigned int x = 0; x < width; ++x) {
destination += stride; 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. // Only support 32bits RGBA BMP for now.
return hBitmap; return hBitmap;
@ -911,14 +919,14 @@ static HBITMAP DecodePNGIcon(LPBYTE imageBuffer, size_t imageSize) {
bmi.bmiHeader.biCompression = BI_RGB; bmi.bmiHeader.biCompression = BI_RGB;
// bitmap dimensions // bitmap dimensions
LONG lBytesPerLine = (((bmi.bmiHeader.biWidth * bmi.bmiHeader.biBitCount) + 31) / 32 * 4); LONG stride = (((bmi.bmiHeader.biWidth * bmi.bmiHeader.biBitCount) + 31) / 32 * 4);
bmi.bmiHeader.biSizeImage = (DWORD) (lBytesPerLine * bmi.bmiHeader.biHeight); bmi.bmiHeader.biSizeImage = (DWORD) (stride * bmi.bmiHeader.biHeight);
// allocate buffer for pixels // allocate buffer for pixels
LPBYTE pbyPixels; // BMP buffer LPBYTE pbyPixels; // BMP buffer
hBitmap = CreateDIBSection(hWindowDC, &bmi, DIB_RGB_COLORS, (VOID **)&pbyPixels, NULL, 0); hBitmap = CreateDIBSection(hWindowDC, &bmi, DIB_RGB_COLORS, (VOID **)&pbyPixels, NULL, 0);
if (hBitmap) if (hBitmap)
memcpy(pbyPixels, pbyImage, bmi.bmiHeader.biSizeImage); memcpy(pbyPixels, pbyImage, bmi.bmiHeader.biSizeImage);
} }
if (pbyImage != NULL) 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); return select(__fd_count, __read_fds, __write_fds, __exception_fds, __timeout);
} }

View file

@ -215,8 +215,10 @@ public class MainScreenView extends PanAndScaleView {
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
float pointerX = event.getX(actionIndex);
float pointerY = event.getY(actionIndex);
post(() -> { 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); currentButtonTouched.remove(actionIndex);
preventToScroll = currentButtonTouched.size() > 0; preventToScroll = currentButtonTouched.size() > 0;