@@ -788,48 +788,35 @@ gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
788
788
{
789
789
GimpColorProfile * new_profile ;
790
790
cmsHPROFILE target_profile ;
791
- GimpMatrix3 matrix ;
792
- cmsCIEXYZ red ;
793
- cmsCIEXYZ green ;
794
- cmsCIEXYZ blue ;
791
+ GimpMatrix3 matrix = { 0 , };
795
792
cmsCIEXYZ * whitepoint ;
796
793
cmsToneCurve * curve ;
797
794
const gchar * model ;
798
795
gchar * new_model ;
799
796
800
797
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile ), NULL );
801
798
802
- if (! gimp_color_profile_get_rgb_matrix_colorants (profile , & matrix ))
803
- return NULL ;
799
+ if (gimp_color_profile_is_rgb (profile ))
800
+ {
801
+ if (! gimp_color_profile_get_rgb_matrix_colorants (profile , & matrix ))
802
+ return NULL ;
803
+ }
804
+ else if (! gimp_color_profile_is_gray (profile ))
805
+ {
806
+ return NULL ;
807
+ }
804
808
805
809
whitepoint = cmsReadTag (profile -> priv -> lcms_profile ,
806
810
cmsSigMediaWhitePointTag );
807
811
808
- red .X = matrix .coeff [0 ][0 ];
809
- red .Y = matrix .coeff [0 ][1 ];
810
- red .Z = matrix .coeff [0 ][2 ];
811
-
812
- green .X = matrix .coeff [1 ][0 ];
813
- green .Y = matrix .coeff [1 ][1 ];
814
- green .Z = matrix .coeff [1 ][2 ];
815
-
816
- blue .X = matrix .coeff [2 ][0 ];
817
- blue .Y = matrix .coeff [2 ][1 ];
818
- blue .Z = matrix .coeff [2 ][2 ];
819
-
820
812
target_profile = cmsCreateProfilePlaceholder (0 );
821
813
822
814
cmsSetProfileVersion (target_profile , 4.3 );
823
815
cmsSetDeviceClass (target_profile , cmsSigDisplayClass );
824
- cmsSetColorSpace (target_profile , cmsSigRgbData );
825
816
cmsSetPCS (target_profile , cmsSigXYZData );
826
817
827
818
cmsWriteTag (target_profile , cmsSigMediaWhitePointTag , whitepoint );
828
819
829
- cmsWriteTag (target_profile , cmsSigRedColorantTag , & red );
830
- cmsWriteTag (target_profile , cmsSigGreenColorantTag , & green );
831
- cmsWriteTag (target_profile , cmsSigBlueColorantTag , & blue );
832
-
833
820
if (linear )
834
821
{
835
822
/* linear light */
@@ -850,9 +837,40 @@ gimp_color_profile_new_from_color_profile (GimpColorProfile *profile,
850
837
"sRGB gamma variant generated by GIMP" );
851
838
}
852
839
853
- cmsWriteTag (target_profile , cmsSigRedTRCTag , curve );
854
- cmsWriteTag (target_profile , cmsSigGreenTRCTag , curve );
855
- cmsWriteTag (target_profile , cmsSigBlueTRCTag , curve );
840
+ if (gimp_color_profile_is_rgb (profile ))
841
+ {
842
+ cmsCIEXYZ red ;
843
+ cmsCIEXYZ green ;
844
+ cmsCIEXYZ blue ;
845
+
846
+ cmsSetColorSpace (target_profile , cmsSigRgbData );
847
+
848
+ red .X = matrix .coeff [0 ][0 ];
849
+ red .Y = matrix .coeff [0 ][1 ];
850
+ red .Z = matrix .coeff [0 ][2 ];
851
+
852
+ green .X = matrix .coeff [1 ][0 ];
853
+ green .Y = matrix .coeff [1 ][1 ];
854
+ green .Z = matrix .coeff [1 ][2 ];
855
+
856
+ blue .X = matrix .coeff [2 ][0 ];
857
+ blue .Y = matrix .coeff [2 ][1 ];
858
+ blue .Z = matrix .coeff [2 ][2 ];
859
+
860
+ cmsWriteTag (target_profile , cmsSigRedColorantTag , & red );
861
+ cmsWriteTag (target_profile , cmsSigGreenColorantTag , & green );
862
+ cmsWriteTag (target_profile , cmsSigBlueColorantTag , & blue );
863
+
864
+ cmsWriteTag (target_profile , cmsSigRedTRCTag , curve );
865
+ cmsWriteTag (target_profile , cmsSigGreenTRCTag , curve );
866
+ cmsWriteTag (target_profile , cmsSigBlueTRCTag , curve );
867
+ }
868
+ else
869
+ {
870
+ cmsSetColorSpace (target_profile , cmsSigGrayData );
871
+
872
+ cmsWriteTag (target_profile , cmsSigGrayTRCTag , curve );
873
+ }
856
874
857
875
cmsFreeToneCurve (curve );
858
876
@@ -906,7 +924,7 @@ gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile)
906
924
}
907
925
908
926
/**
909
- * gimp_color_profile_new_linear_rgb_from_color_profile :
927
+ * gimp_color_profile_new_linear_gamma_from_color_profile :
910
928
* @profile: a #GimpColorProfile
911
929
*
912
930
* This function creates a new RGB #GimpColorProfile with a linear TRC
@@ -918,7 +936,7 @@ gimp_color_profile_new_srgb_gamma_from_color_profile (GimpColorProfile *profile)
918
936
* Since: 2.10
919
937
**/
920
938
GimpColorProfile *
921
- gimp_color_profile_new_linear_rgb_from_color_profile (GimpColorProfile * profile )
939
+ gimp_color_profile_new_linear_gamma_from_color_profile (GimpColorProfile * profile )
922
940
{
923
941
g_return_val_if_fail (GIMP_IS_COLOR_PROFILE (profile ), NULL );
924
942
0 commit comments