src/macosx/native/sun/awt/ImageSurfaceData.m

Print this page




 832                     p1b = ((p1b * 0xff) + 0x7f) / p1a;
 833 
 834                     // clamp
 835                     p1r = (p1r <= 0xff) ? p1r : 0xff;
 836                     p1g = (p1g <= 0xff) ? p1g : 0xff;
 837                     p1b = (p1b <= 0xff) ? p1b : 0xff;
 838                 }
 839                 else
 840                 {
 841                     p1r = 0;
 842                     p1g = 0;
 843                     p1b = 0;
 844                 }
 845 
 846                 cacheIndex = (UInt16)(((p1a & indexMask) << 8) | ((p1r & indexMask) << 4) | ((p1g & indexMask) << 0) | ((p1b & indexMask) >> 4));
 847                 if (indexedColorTable[cacheIndex] == invalidIndex)
 848                 {
 849                     indexOfBest = 0;
 850                     distanceOfBest = DBL_MAX;
 851 
 852                     for (i=0; i<lutDataSize; i++)
 853                     {
 854                         p2 = lutdata[i];
 855 
 856                         da = p1a - ((p2 >> 24) & mask);
 857                         dr = p1r - ((p2 >> 16) & mask);
 858                         dg = p1g - ((p2 >> 8) & mask);
 859                         db = p1b - ((p2 >> 0) & mask);
 860 
 861                         distance = sqrt((da*da)+(dr*dr)+(dg*dg)+(db*db));
 862                         if (distance < distanceOfBest)
 863                         {
 864                             distanceOfBest = distance;
 865                             indexOfBest = i;
 866                         }
 867                     }
 868 
 869                     indexedColorTable[cacheIndex] = indexOfBest;
 870                 }
 871                 else
 872                 {


 882                 indexOfBest = indexOfBestCached;
 883             }
 884 
 885             *pixelsDst = indexOfBest;
 886 
 887             pixelsDst++;
 888             pixelsSrc++;
 889         }
 890         pixelsSrc += skipSrc;
 891         pixelsDst += skipDst;
 892     }
 893 
 894     return indexedColorTable;
 895 }
 896 
 897 // callback from CG telling us it's done with the data. <rdar://problem/4762033>
 898 static void releaseDataFromProvider(void *info, const void *data, size_t size)
 899 {
 900     if (data != NULL)
 901     {
 902         free(data);
 903     }
 904 }
 905 
 906 IMAGE_SURFACE_INLINE void createContext(JNIEnv *env, ImageSDOps *isdo)
 907 {
 908 PRINT("createContext")
 909 
 910     QuartzSDOps *qsdo = (QuartzSDOps*)isdo;
 911     if (qsdo->cgRef == NULL)  // lazy creation
 912     {
 913         size_t bitsPerComponent = isdo->contextInfo.bitsPerComponent;
 914         CGColorSpaceRef colorSpace = isdo->contextInfo.colorSpace;
 915         CGImageAlphaInfo alphaInfo = isdo->contextInfo.alphaInfo;
 916 
 917         size_t bytesPerRow = isdo->contextInfo.bytesPerRow;
 918         size_t size = bytesPerRow * isdo->height;
 919         isdo->nativePixels = malloc(size);
 920 
 921         if (isdo->nativePixels == NULL)
 922         {


1560     return isdo;
1561 }
1562 void UnlockImage(JNIEnv* env, ImageSDOps* isdo)
1563 {
1564 PRINT("UnlockImage")
1565 
1566     // don't do that since the native pixels haven't changed (Java pixels == native pixels)
1567     //syncToJavaPixels(env, isdo);
1568 
1569     pthread_mutex_unlock(&isdo->lock);
1570 }
1571 
1572 JNIEXPORT jobject JNICALL Java_sun_awt_image_BufImgSurfaceData_getSurfaceData
1573     (JNIEnv *env, jclass bisd, jobject bufImg)
1574 {
1575     static jfieldID sDataID = 0;
1576     if (sDataID == 0)
1577     {
1578         static char *bimgName = "java/awt/image/BufferedImage";
1579         jclass bimg = (*env)->FindClass(env, bimgName);

1580         sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");

1581     }
1582 
1583     return (*env)->GetObjectField(env, bufImg, sDataID);
1584 }
1585 
1586 JNIEXPORT void JNICALL Java_sun_awt_image_BufImgSurfaceData_setSurfaceData
1587     (JNIEnv *env, jclass bisd, jobject bufImg, jobject sData)
1588 {
1589     static jfieldID sDataID = 0;
1590     if (sDataID == 0)
1591     {
1592         static char *bimgName = "java/awt/image/BufferedImage";
1593         jclass bimg = (*env)->FindClass(env, bimgName);

1594         sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");

1595     }
1596 
1597     (*env)->SetObjectField(env, bufImg, sDataID, sData);
1598 }
1599 
1600 JNIEXPORT void JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_initIDs(JNIEnv *env, jclass bisd)
1601 {
1602 //PRINT("initIDs")
1603     // copied from Java_sun_awt_image_BufImgSurfaceData_initIDs in BufImgSurfaceData.c
1604     {
1605         static char *icmName = "java/awt/image/IndexColorModel";
1606         jclass icm;
1607 
1608         if (sizeof(BufImgRIPrivate) > SD_RASINFO_PRIVATE_SIZE) {
1609         JNU_ThrowInternalError(env, "Private RasInfo structure too large!");
1610         return;
1611         }
1612 
1613         icm = (*env)->FindClass(env, icmName);
1614         if (icm == NULL) {
1615             return;
1616         }
1617 
1618         rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I");
1619         allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z");
1620         mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I");
1621         CMpDataID = (*env)->GetFieldID(env, icm, "pData", "J");
1622         if (allGrayID == 0 || rgbID == 0 || mapSizeID == 0 || CMpDataID == 0) {
1623         JNU_ThrowInternalError(env, "Could not get field IDs");
1624         }
1625     }
1626 
1627     gColorspaceRGB = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
1628     gColorspaceGray = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray);
1629 //fprintf(stderr, "gColorspaceRGB=%p, gColorspaceGray=%p\n", gColorspaceRGB, gColorspaceGray);
1630 }
1631 
1632 JNIEXPORT jobject JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_getSurfaceData
1633     (JNIEnv *env, jclass bisd, jobject bufImg)
1634 {
1635 PRINT("getSurfaceData")
1636 
1637     return JNFGetObjectField(env, bufImg, jm_SurfaceData);
1638 }
1639 
1640 JNIEXPORT void JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_setSurfaceData
1641     (JNIEnv *env, jclass bisd, jobject bufImg, jobject sData)
1642 {
1643 PRINT("setSurfaceData")
1644 


1778 
1779     pthread_mutexattr_t attr;
1780     pthread_mutexattr_init(&attr);
1781     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
1782     pthread_mutex_init(&isdo->lock, &attr);
1783     pthread_mutex_lock(&isdo->lock);
1784     pthread_mutexattr_destroy(&attr);
1785 
1786     // copied (and modified) from Java_sun_awt_image_BufImgSurfaceData_initRaster in BufImgSurfaceData.c
1787     {
1788         BufImgSDOps *bisdo =
1789         //(BufImgSDOps*)SurfaceData_InitOps(env, bisd, sizeof(BufImgSDOps));
1790         (BufImgSDOps*)isdo;
1791         //bisdo->sdOps.Lock = BufImg_Lock;
1792         //bisdo->sdOps.GetRasInfo = BufImg_GetRasInfo;
1793         //bisdo->sdOps.Release = BufImg_Release;
1794         //bisdo->sdOps.Unlock = NULL;
1795         //bisdo->sdOps.Dispose = BufImg_Dispose;
1796 
1797         bisdo->array = (*env)->NewWeakGlobalRef(env, array);

1798         bisdo->offset = offset;
1799         //bisdo->scanStr = scanStr;
1800         bisdo->scanStr = scanStride;
1801         //bisdo->pixStr = pixStr;
1802         bisdo->pixStr = pixelStride;
1803         if (!icm) {
1804         bisdo->lutarray = NULL;
1805         bisdo->lutsize = 0;
1806         bisdo->icm = NULL;
1807         } else {
1808         jobject lutarray = (*env)->GetObjectField(env, icm, rgbID);
1809         bisdo->lutarray = (*env)->NewWeakGlobalRef(env, lutarray);

1810         bisdo->lutsize = (*env)->GetIntField(env, icm, mapSizeID);
1811         bisdo->icm = (*env)->NewWeakGlobalRef(env, icm);

1812         }
1813         bisdo->rasbounds.x1 = 0;
1814         bisdo->rasbounds.y1 = 0;
1815         bisdo->rasbounds.x2 = width;
1816         bisdo->rasbounds.y2 = height;
1817     }
1818 
1819     isdo->nrOfPixelsOwners = 0;
1820 
1821     isdo->contextInfo                    = sDefaultContextInfo[type];
1822     isdo->imageInfo                        = sDefaultImageInfo[type];
1823 
1824     isdo->contextInfo.bytesPerRow        = width*isdo->contextInfo.bytesPerPixel;
1825     isdo->imageInfo.bytesPerRow            = width*isdo->imageInfo.bytesPerPixel;
1826 
1827     switch (type)
1828     {
1829         case java_awt_image_BufferedImage_TYPE_BYTE_GRAY:
1830             isdo->contextInfo.colorSpace = isdo->imageInfo.colorSpace = gColorspaceGray;
1831             break;


1870             jint transparency = JNFGetIntField(env, icm, jm_transparency);
1871             jint transparent_index = -1;
1872             if (transparency == java_awt_Transparency_BITMASK)
1873             {
1874                 transparent_index = JNFGetIntField(env, icm, jm_transparent_index);
1875             }
1876 
1877             Pixel32bit* lutdata = (Pixel32bit*)((*env)->GetPrimitiveArrayCritical(env, lutarray, NULL));
1878             if (lutdata != NULL)
1879             {
1880                 isdo->lutData = NULL;
1881 
1882                 isdo->lutData = malloc(isdo->lutDataSize * sizeof(Pixel32bit));
1883                 if (isdo->lutData != NULL)
1884                 {
1885                     if (transparency == java_awt_Transparency_BITMASK)
1886                     {
1887                         Pixel32bit* src = lutdata;
1888                         Pixel32bit* dst = isdo->lutData;
1889                         jint i;
1890                         for (i=0; i<isdo->lutDataSize; i++)
1891                         {
1892                             if (i != transparent_index)
1893                             {
1894                                 *dst = *src;
1895                                 // rdar://problem/3390518 - don't force all indexed colors
1896                                 // to be fully opaque. They could be set up for us.
1897                                 // we used to call:  *dst = 0xff000000 | *src;
1898                                 // but that was forcing colors to be opaque when developers
1899                                 // could have set the alpha.
1900                             }
1901                             else
1902                             {
1903                                 *dst = 0x00000000; // mark as translucent color
1904                             }
1905                             dst++; src++;
1906                         }
1907                     }
1908                     else //if ((transparency == java_awt_Transparency_OPAQUE) || (transparency == java_awt_Transparency_TRANSLUCENT))
1909                     {
1910                         jint mask = 0x00000000;
1911                         // <rdar://4224874> If the color model is OPAQUE than we need to create an opaque image for performance purposes.
1912                         // the default alphaInfo for INDEXED images is kCGImageAlphaFirst. Therefore we need to special case this.
1913                         if ((transparency == java_awt_Transparency_OPAQUE))
1914                         {
1915                             isdo->imageInfo.alphaInfo = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host;
1916                             mask = 0xff000000; // this is just a safeguard to make sure we fill the alpha
1917                         }
1918 
1919                         Pixel32bit* src = lutdata;
1920                         Pixel32bit* dst = isdo->lutData;
1921                         jint i;
1922                         for (i=0; i<isdo->lutDataSize; i++)
1923                         {
1924                             *dst = *src | mask;
1925                             dst++; src++;
1926                         }
1927                     }
1928 
1929                     (*env)->ReleasePrimitiveArrayCritical(env, lutarray, lutdata, 0);
1930                 }
1931                 else
1932                 {
1933                     fprintf(stderr, "ERROR: malloc returns NULL for isdo->lutData in initRaster!\n");
1934                 }
1935             }
1936             else
1937             {
1938                 fprintf(stderr, "ERROR: GetPrimitiveArrayCritical returns NULL for lutdata in initRaster!\n");
1939             }
1940         }
1941         (*env)->DeleteLocalRef(env, lutarray);
1942     }




 832                     p1b = ((p1b * 0xff) + 0x7f) / p1a;
 833 
 834                     // clamp
 835                     p1r = (p1r <= 0xff) ? p1r : 0xff;
 836                     p1g = (p1g <= 0xff) ? p1g : 0xff;
 837                     p1b = (p1b <= 0xff) ? p1b : 0xff;
 838                 }
 839                 else
 840                 {
 841                     p1r = 0;
 842                     p1g = 0;
 843                     p1b = 0;
 844                 }
 845 
 846                 cacheIndex = (UInt16)(((p1a & indexMask) << 8) | ((p1r & indexMask) << 4) | ((p1g & indexMask) << 0) | ((p1b & indexMask) >> 4));
 847                 if (indexedColorTable[cacheIndex] == invalidIndex)
 848                 {
 849                     indexOfBest = 0;
 850                     distanceOfBest = DBL_MAX;
 851 
 852                     for (i=0; (unsigned)i<lutDataSize; i++)
 853                     {
 854                         p2 = lutdata[i];
 855 
 856                         da = p1a - ((p2 >> 24) & mask);
 857                         dr = p1r - ((p2 >> 16) & mask);
 858                         dg = p1g - ((p2 >> 8) & mask);
 859                         db = p1b - ((p2 >> 0) & mask);
 860 
 861                         distance = sqrt((da*da)+(dr*dr)+(dg*dg)+(db*db));
 862                         if (distance < distanceOfBest)
 863                         {
 864                             distanceOfBest = distance;
 865                             indexOfBest = i;
 866                         }
 867                     }
 868 
 869                     indexedColorTable[cacheIndex] = indexOfBest;
 870                 }
 871                 else
 872                 {


 882                 indexOfBest = indexOfBestCached;
 883             }
 884 
 885             *pixelsDst = indexOfBest;
 886 
 887             pixelsDst++;
 888             pixelsSrc++;
 889         }
 890         pixelsSrc += skipSrc;
 891         pixelsDst += skipDst;
 892     }
 893 
 894     return indexedColorTable;
 895 }
 896 
 897 // callback from CG telling us it's done with the data. <rdar://problem/4762033>
 898 static void releaseDataFromProvider(void *info, const void *data, size_t size)
 899 {
 900     if (data != NULL)
 901     {
 902         free((void*)data);
 903     }
 904 }
 905 
 906 IMAGE_SURFACE_INLINE void createContext(JNIEnv *env, ImageSDOps *isdo)
 907 {
 908 PRINT("createContext")
 909 
 910     QuartzSDOps *qsdo = (QuartzSDOps*)isdo;
 911     if (qsdo->cgRef == NULL)  // lazy creation
 912     {
 913         size_t bitsPerComponent = isdo->contextInfo.bitsPerComponent;
 914         CGColorSpaceRef colorSpace = isdo->contextInfo.colorSpace;
 915         CGImageAlphaInfo alphaInfo = isdo->contextInfo.alphaInfo;
 916 
 917         size_t bytesPerRow = isdo->contextInfo.bytesPerRow;
 918         size_t size = bytesPerRow * isdo->height;
 919         isdo->nativePixels = malloc(size);
 920 
 921         if (isdo->nativePixels == NULL)
 922         {


1560     return isdo;
1561 }
1562 void UnlockImage(JNIEnv* env, ImageSDOps* isdo)
1563 {
1564 PRINT("UnlockImage")
1565 
1566     // don't do that since the native pixels haven't changed (Java pixels == native pixels)
1567     //syncToJavaPixels(env, isdo);
1568 
1569     pthread_mutex_unlock(&isdo->lock);
1570 }
1571 
1572 JNIEXPORT jobject JNICALL Java_sun_awt_image_BufImgSurfaceData_getSurfaceData
1573     (JNIEnv *env, jclass bisd, jobject bufImg)
1574 {
1575     static jfieldID sDataID = 0;
1576     if (sDataID == 0)
1577     {
1578         static char *bimgName = "java/awt/image/BufferedImage";
1579         jclass bimg = (*env)->FindClass(env, bimgName);
1580         CHECK_NULL_RETURN(bimg, NULL);
1581         sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");
1582         CHECK_NULL_RETURN(sDataID, NULL);
1583     }
1584 
1585     return (*env)->GetObjectField(env, bufImg, sDataID);
1586 }
1587 
1588 JNIEXPORT void JNICALL Java_sun_awt_image_BufImgSurfaceData_setSurfaceData
1589     (JNIEnv *env, jclass bisd, jobject bufImg, jobject sData)
1590 {
1591     static jfieldID sDataID = 0;
1592     if (sDataID == 0)
1593     {
1594         static char *bimgName = "java/awt/image/BufferedImage";
1595         jclass bimg = (*env)->FindClass(env, bimgName);
1596         CHECK_NULL(bimg);
1597         sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");
1598         CHECK_NULL(sDataID);
1599     }
1600 
1601     (*env)->SetObjectField(env, bufImg, sDataID, sData);
1602 }
1603 
1604 JNIEXPORT void JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_initIDs(JNIEnv *env, jclass bisd)
1605 {
1606 //PRINT("initIDs")
1607     // copied from Java_sun_awt_image_BufImgSurfaceData_initIDs in BufImgSurfaceData.c
1608     {
1609         static char *icmName = "java/awt/image/IndexColorModel";
1610         jclass icm;
1611 
1612         if (sizeof(BufImgRIPrivate) > SD_RASINFO_PRIVATE_SIZE) {
1613         JNU_ThrowInternalError(env, "Private RasInfo structure too large!");
1614         return;
1615         }
1616 
1617         CHECK_NULL(icm = (*env)->FindClass(env, icmName));
1618         CHECK_NULL(rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I"));
1619         CHECK_NULL(allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z"));
1620         CHECK_NULL(mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I"));
1621         CHECK_NULL(CMpDataID = (*env)->GetFieldID(env, icm, "pData", "J"));







1622     }
1623 
1624     gColorspaceRGB = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
1625     gColorspaceGray = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray);
1626 //fprintf(stderr, "gColorspaceRGB=%p, gColorspaceGray=%p\n", gColorspaceRGB, gColorspaceGray);
1627 }
1628 
1629 JNIEXPORT jobject JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_getSurfaceData
1630     (JNIEnv *env, jclass bisd, jobject bufImg)
1631 {
1632 PRINT("getSurfaceData")
1633 
1634     return JNFGetObjectField(env, bufImg, jm_SurfaceData);
1635 }
1636 
1637 JNIEXPORT void JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_setSurfaceData
1638     (JNIEnv *env, jclass bisd, jobject bufImg, jobject sData)
1639 {
1640 PRINT("setSurfaceData")
1641 


1775 
1776     pthread_mutexattr_t attr;
1777     pthread_mutexattr_init(&attr);
1778     pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
1779     pthread_mutex_init(&isdo->lock, &attr);
1780     pthread_mutex_lock(&isdo->lock);
1781     pthread_mutexattr_destroy(&attr);
1782 
1783     // copied (and modified) from Java_sun_awt_image_BufImgSurfaceData_initRaster in BufImgSurfaceData.c
1784     {
1785         BufImgSDOps *bisdo =
1786         //(BufImgSDOps*)SurfaceData_InitOps(env, bisd, sizeof(BufImgSDOps));
1787         (BufImgSDOps*)isdo;
1788         //bisdo->sdOps.Lock = BufImg_Lock;
1789         //bisdo->sdOps.GetRasInfo = BufImg_GetRasInfo;
1790         //bisdo->sdOps.Release = BufImg_Release;
1791         //bisdo->sdOps.Unlock = NULL;
1792         //bisdo->sdOps.Dispose = BufImg_Dispose;
1793 
1794         bisdo->array = (*env)->NewWeakGlobalRef(env, array);
1795         if (array != NULL) CHECK_NULL(bisdo->array);
1796         bisdo->offset = offset;
1797         //bisdo->scanStr = scanStr;
1798         bisdo->scanStr = scanStride;
1799         //bisdo->pixStr = pixStr;
1800         bisdo->pixStr = pixelStride;
1801         if (!icm) {
1802         bisdo->lutarray = NULL;
1803         bisdo->lutsize = 0;
1804         bisdo->icm = NULL;
1805         } else {
1806         jobject lutarray = (*env)->GetObjectField(env, icm, rgbID);
1807         bisdo->lutarray = (*env)->NewWeakGlobalRef(env, lutarray);
1808             if (lutarray != NULL) CHECK_NULL(bisdo->lutarray);
1809         bisdo->lutsize = (*env)->GetIntField(env, icm, mapSizeID);
1810         bisdo->icm = (*env)->NewWeakGlobalRef(env, icm);
1811             if (icm != NULL) CHECK_NULL(bisdo->icm);
1812         }
1813         bisdo->rasbounds.x1 = 0;
1814         bisdo->rasbounds.y1 = 0;
1815         bisdo->rasbounds.x2 = width;
1816         bisdo->rasbounds.y2 = height;
1817     }
1818 
1819     isdo->nrOfPixelsOwners = 0;
1820 
1821     isdo->contextInfo                    = sDefaultContextInfo[type];
1822     isdo->imageInfo                        = sDefaultImageInfo[type];
1823 
1824     isdo->contextInfo.bytesPerRow        = width*isdo->contextInfo.bytesPerPixel;
1825     isdo->imageInfo.bytesPerRow            = width*isdo->imageInfo.bytesPerPixel;
1826 
1827     switch (type)
1828     {
1829         case java_awt_image_BufferedImage_TYPE_BYTE_GRAY:
1830             isdo->contextInfo.colorSpace = isdo->imageInfo.colorSpace = gColorspaceGray;
1831             break;


1870             jint transparency = JNFGetIntField(env, icm, jm_transparency);
1871             jint transparent_index = -1;
1872             if (transparency == java_awt_Transparency_BITMASK)
1873             {
1874                 transparent_index = JNFGetIntField(env, icm, jm_transparent_index);
1875             }
1876 
1877             Pixel32bit* lutdata = (Pixel32bit*)((*env)->GetPrimitiveArrayCritical(env, lutarray, NULL));
1878             if (lutdata != NULL)
1879             {
1880                 isdo->lutData = NULL;
1881 
1882                 isdo->lutData = malloc(isdo->lutDataSize * sizeof(Pixel32bit));
1883                 if (isdo->lutData != NULL)
1884                 {
1885                     if (transparency == java_awt_Transparency_BITMASK)
1886                     {
1887                         Pixel32bit* src = lutdata;
1888                         Pixel32bit* dst = isdo->lutData;
1889                         jint i;
1890                         for (i=0; (unsigned)i<isdo->lutDataSize; i++)
1891                         {
1892                             if (i != transparent_index)
1893                             {
1894                                 *dst = *src;
1895                                 // rdar://problem/3390518 - don't force all indexed colors
1896                                 // to be fully opaque. They could be set up for us.
1897                                 // we used to call:  *dst = 0xff000000 | *src;
1898                                 // but that was forcing colors to be opaque when developers
1899                                 // could have set the alpha.
1900                             }
1901                             else
1902                             {
1903                                 *dst = 0x00000000; // mark as translucent color
1904                             }
1905                             dst++; src++;
1906                         }
1907                     }
1908                     else //if ((transparency == java_awt_Transparency_OPAQUE) || (transparency == java_awt_Transparency_TRANSLUCENT))
1909                     {
1910                         jint mask = 0x00000000;
1911                         // <rdar://4224874> If the color model is OPAQUE than we need to create an opaque image for performance purposes.
1912                         // the default alphaInfo for INDEXED images is kCGImageAlphaFirst. Therefore we need to special case this.
1913                         if ((transparency == java_awt_Transparency_OPAQUE))
1914                         {
1915                             isdo->imageInfo.alphaInfo = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host;
1916                             mask = 0xff000000; // this is just a safeguard to make sure we fill the alpha
1917                         }
1918 
1919                         Pixel32bit* src = lutdata;
1920                         Pixel32bit* dst = isdo->lutData;
1921                         jint i;
1922                         for (i=0; (unsigned)i<isdo->lutDataSize; i++)
1923                         {
1924                             *dst = *src | mask;
1925                             dst++; src++;
1926                         }
1927                     }
1928 
1929                     (*env)->ReleasePrimitiveArrayCritical(env, lutarray, lutdata, 0);
1930                 }
1931                 else
1932                 {
1933                     fprintf(stderr, "ERROR: malloc returns NULL for isdo->lutData in initRaster!\n");
1934                 }
1935             }
1936             else
1937             {
1938                 fprintf(stderr, "ERROR: GetPrimitiveArrayCritical returns NULL for lutdata in initRaster!\n");
1939             }
1940         }
1941         (*env)->DeleteLocalRef(env, lutarray);
1942     }