41 42 #ifndef WS_EX_LAYERED 43 #define WS_EX_LAYERED 0x80000 44 #endif 45 46 #ifndef ULW_ALPHA 47 #define ULW_ALPHA 0x00000002 48 #endif 49 50 #ifndef AC_SRC_OVER 51 #define AC_SRC_OVER 0x00 52 #endif 53 54 #ifndef AC_SRC_ALPHA 55 #define AC_SRC_ALPHA 0x01 56 #endif 57 58 #define WM_SPLASHUPDATE WM_USER+1 59 #define WM_SPLASHRECONFIGURE WM_USER+2 60 61 /* Could use npt but decided to cut down on linked code size */ 62 char* SplashConvertStringAlloc(const char* in, int *size) { 63 int len, outChars, rc; 64 WCHAR* buf; 65 if (!in) { 66 return NULL; 67 } 68 len = strlen(in); 69 outChars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, in, len, 70 NULL, 0); 71 buf = (WCHAR*) SAFE_SIZE_ARRAY_ALLOC(malloc, outChars, sizeof(WCHAR)); 72 if (!buf) { 73 return NULL; 74 } 75 rc = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, in, len, 76 buf, outChars); 77 if (rc==0) { 78 free(buf); 79 return NULL; 80 } else { 552 } 553 554 void 555 SplashClosePlatform(Splash * splash) 556 { 557 PostMessage(splash->hWnd, WM_QUIT, 0, 0); 558 } 559 560 void 561 SplashUpdate(Splash * splash) 562 { 563 PostMessage(splash->hWnd, WM_SPLASHUPDATE, 0, 0); 564 } 565 566 void 567 SplashReconfigure(Splash * splash) 568 { 569 PostMessage(splash->hWnd, WM_SPLASHRECONFIGURE, 0, 0); 570 } 571 572 SPLASHEXPORT char* 573 SplashGetScaledImageName(const char* jarName, const char* fileName, 574 float *scaleFactor) 575 { 576 *scaleFactor = 1; 577 return NULL; 578 } | 41 42 #ifndef WS_EX_LAYERED 43 #define WS_EX_LAYERED 0x80000 44 #endif 45 46 #ifndef ULW_ALPHA 47 #define ULW_ALPHA 0x00000002 48 #endif 49 50 #ifndef AC_SRC_OVER 51 #define AC_SRC_OVER 0x00 52 #endif 53 54 #ifndef AC_SRC_ALPHA 55 #define AC_SRC_ALPHA 0x01 56 #endif 57 58 #define WM_SPLASHUPDATE WM_USER+1 59 #define WM_SPLASHRECONFIGURE WM_USER+2 60 61 #define BUFF_SIZE 1024 62 63 /* Could use npt but decided to cut down on linked code size */ 64 char* SplashConvertStringAlloc(const char* in, int *size) { 65 int len, outChars, rc; 66 WCHAR* buf; 67 if (!in) { 68 return NULL; 69 } 70 len = strlen(in); 71 outChars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, in, len, 72 NULL, 0); 73 buf = (WCHAR*) SAFE_SIZE_ARRAY_ALLOC(malloc, outChars, sizeof(WCHAR)); 74 if (!buf) { 75 return NULL; 76 } 77 rc = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, in, len, 78 buf, outChars); 79 if (rc==0) { 80 free(buf); 81 return NULL; 82 } else { 554 } 555 556 void 557 SplashClosePlatform(Splash * splash) 558 { 559 PostMessage(splash->hWnd, WM_QUIT, 0, 0); 560 } 561 562 void 563 SplashUpdate(Splash * splash) 564 { 565 PostMessage(splash->hWnd, WM_SPLASHUPDATE, 0, 0); 566 } 567 568 void 569 SplashReconfigure(Splash * splash) 570 { 571 PostMessage(splash->hWnd, WM_SPLASHRECONFIGURE, 0, 0); 572 } 573 574 jboolean 575 SplashGetScaledImageName(const char* jarName, const char* fileName, 576 float *scaleFactor, char *scaleImageName, 577 const size_t scaledImageLength) 578 { 579 float dpiScaleX = -1.0f; 580 float dpiScaleY = -1.0f; 581 FILE *fp = NULL; 582 *scaleFactor = 1.0; 583 GetScreenDpi(getPrimaryMonitor(), &dpiScaleX, &dpiScaleY); 584 *scaleFactor = dpiScaleX > 0 ? dpiScaleX / 96 : *scaleFactor; 585 if (*scaleFactor > 1.0) { 586 char strDpi[BUFF_SIZE]; 587 char *dupFileName = strdup(fileName); 588 char *fileExtension = strrchr(dupFileName, '.'); 589 char *nameToAppend = ".scale-"; 590 size_t length = 0; 591 int retVal = 0; 592 _snprintf(strDpi, BUFF_SIZE, "%d", (int)dpiScaleX); 593 /*File is missing extension */ 594 if (fileExtension == NULL) { 595 length = strlen(dupFileName) + strlen(nameToAppend) + 596 strlen(strDpi) + 1; 597 if (length > scaledImageLength) { 598 *scaleFactor = 1; 599 free(dupFileName); 600 return JNI_FALSE; 601 } 602 retVal = _snprintf(scaleImageName, length, "%s%s%s", dupFileName, 603 nameToAppend, strDpi); 604 if (retVal < 0 || (retVal != length - 1)) { 605 *scaleFactor = 1; 606 free(dupFileName); 607 return JNI_FALSE; 608 } 609 } 610 else { 611 size_t length_Without_Ext = fileExtension - dupFileName; 612 length = length_Without_Ext + strlen(nameToAppend) + strlen(strDpi) + 613 strlen(fileExtension) + 1; 614 if (length > scaledImageLength) { 615 *scaleFactor = 1; 616 free(dupFileName); 617 return JNI_FALSE; 618 } 619 retVal = _snprintf(scaleImageName, length, "%.*s%s%s%s", 620 length_Without_Ext, dupFileName, nameToAppend, strDpi, fileExtension); 621 if (retVal < 0 || (retVal != length - 1)) { 622 *scaleFactor = 1; 623 free(dupFileName); 624 return JNI_FALSE; 625 } 626 } 627 free(dupFileName); 628 if (!(fp = fopen(scaleImageName, "r"))) { 629 *scaleFactor = 1; 630 return JNI_FALSE; 631 } 632 fclose(fp); 633 return JNI_TRUE; 634 } 635 return JNI_FALSE; 636 } |