< 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                 free(dupFileName);
 823                 *scaleFactor = 1;
 824                 return NULL;
 825             }
 826         } else {
 827             int length_without_ext = fileExtension - dupFileName;
 828             length = length_without_ext + 
 829                     strlen(stringToAppend) + strlen(fileExtension) + 1;
 830             scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof (char));
 831             int retVal = snprintf(scaledImgName, length, "%.*s%s%s", 
 832                     length_without_ext, dupFileName, stringToAppend, fileExtension);
 833             if(retVal < 0 || retVal != length - 1) {
 834                 free(scaledImgName);
 835                 free(dupFileName);
 836                 *scaleFactor = 1;
 837                 return NULL;
 838             }
 839         }
 840         free(dupFileName);
 841         FILE *fp;
 842         if (!(fp = fopen(scaledImgName, "r"))) {
 843             *scaleFactor = 1;
 844             free(scaledImgName);
 845             return NULL;
 846         }
 847         fclose(fp);
 848         return scaledImgName;
 849     }
 850     return NULL;
 851 }
 852 
< prev index next >