< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java

Print this page




 857             case JPEG.ADOBE_UNKNOWN:
 858                 if (numChannels == 3) {
 859                     csType.setAttribute("name", "RGB");
 860                 } else if (numChannels == 4) {
 861                     csType.setAttribute("name", "CMYK");
 862                 }
 863                 break;
 864             }
 865             return chroma;
 866         }
 867 
 868         // Neither marker.  Check components
 869         if (numChannels < 3) {
 870             csType.setAttribute("name", "GRAY");
 871             if (numChannels == 2) {
 872                 hasAlpha = true;
 873             }
 874             return chroma;
 875         }
 876 
 877         boolean idsAreJFIF = true;
 878 
 879         for (int i = 0; i < sof.componentSpecs.length; i++) {
 880             int id = sof.componentSpecs[i].componentId;
 881             if ((id < 1) || (id >= sof.componentSpecs.length)) {
 882                 idsAreJFIF = false;
 883             }
 884         }
 885 
 886         if (idsAreJFIF) {
 887             csType.setAttribute("name", "YCbCr");
 888             if (numChannels == 4) {
 889                 hasAlpha = true;
 890             }
 891             return chroma;
 892         }
 893 
 894         // Check against the letters
 895         if ((sof.componentSpecs[0].componentId == 'R')
 896             && (sof.componentSpecs[1].componentId == 'G')
 897             && (sof.componentSpecs[2].componentId == 'B')){
 898 
 899             csType.setAttribute("name", "RGB");
 900             if ((numChannels == 4)
 901                 && (sof.componentSpecs[3].componentId == 'A')) {
 902                 hasAlpha = true;
 903             }




 857             case JPEG.ADOBE_UNKNOWN:
 858                 if (numChannels == 3) {
 859                     csType.setAttribute("name", "RGB");
 860                 } else if (numChannels == 4) {
 861                     csType.setAttribute("name", "CMYK");
 862                 }
 863                 break;
 864             }
 865             return chroma;
 866         }
 867 
 868         // Neither marker.  Check components
 869         if (numChannels < 3) {
 870             csType.setAttribute("name", "GRAY");
 871             if (numChannels == 2) {
 872                 hasAlpha = true;
 873             }
 874             return chroma;
 875         }
 876 
 877         boolean idsAreJFIF = false;
 878 
 879         int cid0 = sof.componentSpecs[0].componentId;
 880         int cid1 = sof.componentSpecs[1].componentId;
 881         int cid2 = sof.componentSpecs[2].componentId;
 882         if ((cid0 == 1) && (cid1 == 2) && (cid2 == 3)) {
 883             idsAreJFIF = true;
 884         }
 885 
 886         if (idsAreJFIF) {
 887             csType.setAttribute("name", "YCbCr");
 888             if (numChannels == 4) {
 889                 hasAlpha = true;
 890             }
 891             return chroma;
 892         }
 893 
 894         // Check against the letters
 895         if ((sof.componentSpecs[0].componentId == 'R')
 896             && (sof.componentSpecs[1].componentId == 'G')
 897             && (sof.componentSpecs[2].componentId == 'B')){
 898 
 899             csType.setAttribute("name", "RGB");
 900             if ((numChannels == 4)
 901                 && (sof.componentSpecs[3].componentId == 'A')) {
 902                 hasAlpha = true;
 903             }


< prev index next >