< prev index next >

src/java.desktop/windows/native/libsplashscreen/splashscreen_sys.c

Print this page




  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 {


 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 {


 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 SPLASHEXPORT char*
 575 SplashGetScaledImageName(const char* jarName, const char* fileName,
 576                            float *scaleFactor)
 577 {
 578     *scaleFactor = 1.0;
 579     float dpiScale = -1.0f;
 580 
 581     dpiScale = GetScreenDpi();
 582     *scaleFactor = dpiScale > 0 ? dpiScale / 96 : *scaleFactor;
 583 
 584     if (*scaleFactor > 1.0) {
 585 
 586         char strDpi[BUFF_SIZE];
 587         _snprintf(strDpi, BUFF_SIZE, "%d", (int)dpiScale);
 588         char *dupFileName = strdup(fileName);
 589         char *fileExtension = strrchr(dupFileName, '.');
 590         char *scaledImgName = NULL;
 591         char *nameToAppend = ".scale-";
 592         size_t length = 0;
 593 
 594         /*File is missing extension */
 595         if (fileExtension == NULL) {
 596             length = strlen(dupFileName) + strlen(nameToAppend) +
 597                     strlen(strDpi) + 1;
 598             scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc,length, sizeof(char));
 599             _snprintf(scaledImgName, length, "%s%s%s", dupFileName,
 600                     nameToAppend, strDpi);
 601         } else {
 602             length = fileExtension - dupFileName + 1;
 603             char *fNameWithoutExt = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof(char));
 604             memcpy(fNameWithoutExt, dupFileName, length);
 605             fNameWithoutExt[length - 1] = '\0';
 606             length = length + strlen(nameToAppend) + strlen(strDpi) +
 607                     strlen(fileExtension) + 1;
 608             scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof(char));
 609             _snprintf(scaledImgName, length, "%s%s%s%s",
 610                     fNameWithoutExt, nameToAppend, strDpi, fileExtension);
 611             free(fNameWithoutExt);
 612         }
 613         free(dupFileName);
 614         FILE *fp = NULL;
 615         if (!(fp = fopen(scaledImgName, "r"))) {
 616             *scaleFactor = 1;
 617             free(scaledImgName);
 618             return NULL;
 619         }
 620         fclose(fp);
 621         return scaledImgName;
 622     }
 623     return NULL;
 624 }
 625 
< prev index next >