< prev index next >

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

Print this page




 785 void
 786 SplashClosePlatform(Splash * splash) {
 787     sendctl(splash, SPLASHCTL_QUIT);
 788 }
 789 
 790 void
 791 SplashUpdate(Splash * splash) {
 792     sendctl(splash, SPLASHCTL_UPDATE);
 793 }
 794 
 795 void
 796 SplashReconfigure(Splash * splash) {
 797     sendctl(splash, SPLASHCTL_RECONFIGURE);
 798 }
 799 
 800 SPLASHEXPORT char*
 801 SplashGetScaledImageName(const char* jarName, const char* fileName,
 802                            float *scaleFactor)
 803 {
 804     *scaleFactor = 1;











































 805     return NULL;
 806 }



 785 void
 786 SplashClosePlatform(Splash * splash) {
 787     sendctl(splash, SPLASHCTL_QUIT);
 788 }
 789 
 790 void
 791 SplashUpdate(Splash * splash) {
 792     sendctl(splash, SPLASHCTL_UPDATE);
 793 }
 794 
 795 void
 796 SplashReconfigure(Splash * splash) {
 797     sendctl(splash, SPLASHCTL_RECONFIGURE);
 798 }
 799 
 800 SPLASHEXPORT char*
 801 SplashGetScaledImageName(const char* jarName, const char* fileName,
 802                            float *scaleFactor)
 803 {
 804     *scaleFactor = 1;
 805 #ifndef __linux__
 806     return NULL;
 807 #endif
 808     *scaleFactor = getNativeScaleFactor();
 809     if (*scaleFactor == 2.0) {
 810         char *scaledImgName = NULL;
 811         size_t length = 0;
 812         char *stringToAppend = ".java-scale2x";
 813         char *dupFileName = strdup(fileName);
 814         char *fileExtension = strrchr(dupFileName, '.');
 815         if (fileExtension == NULL) {
 816             length = strlen(dupFileName) + strlen(stringToAppend) + 1;
 817             scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof (char));
 818             int retVal = snprintf(scaledImgName, length, "%s%s",
 819                     dupFileName, stringToAppend);
 820             if(retVal < 0 || (retVal != length - 1)) {
 821                 free(scaledImgName);
 822                 *scaleFactor = 1;
 823                 return NULL;
 824             }
 825         } else {
 826             int length_without_ext = fileExtension - dupFileName;
 827             length = length_without_ext + 
 828                     strlen(stringToAppend) + strlen(fileExtension) + 1;
 829             scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof (char));
 830             int retVal = snprintf(scaledImgName, length, "%.*s%s%s", 
 831                     length_without_ext, dupFileName, stringToAppend, fileExtension);
 832             if(retVal < 0 || retVal != length - 1) {
 833                 free(scaledImgName);
 834                 *scaleFactor = 1;
 835                 return NULL;
 836             }
 837         }
 838         free(dupFileName);
 839         FILE *fp;
 840         if (!(fp = fopen(scaledImgName, "r"))) {
 841             *scaleFactor = 1;
 842             free(scaledImgName);
 843             return NULL;
 844         }
 845         fclose(fp);
 846         return scaledImgName;
 847     }
 848     return NULL;
 849 }
 850 
< prev index next >