@@ -520,6 +520,105 @@ static void CMSExceptionHandler(cmsContext context,cmsUInt32Number severity,
520520 "UnableToTransformColorspace" ,"`%s', %s (#%u)" ,image -> filename ,
521521 message != (char * ) NULL ? message : "no message" ,severity );
522522}
523+
524+ static void TransformDoublePixels (const int id ,const Image * image ,
525+ const LCMSInfo * source_info ,const LCMSInfo * target_info ,
526+ const cmsHTRANSFORM * transform ,Quantum * q )
527+ {
528+ #define GetLCMSPixel (source_info ,pixel ) \
529+ (source_info->scale*QuantumScale*(pixel)+source_info->translate)
530+ #define SetLCMSPixel (target_info ,pixel ) \
531+ ClampToQuantum(target_info->scale*QuantumRange*(pixel)+target_info->translate)
532+
533+ register double
534+ * p ;
535+
536+ register ssize_t
537+ x ;
538+
539+ p = source_info -> pixels [id ];
540+ for (x = 0 ; x < (ssize_t ) image -> columns ; x ++ )
541+ {
542+ * p ++ = GetLCMSPixel (source_info ,GetPixelRed (image ,q ));
543+ if (source_info -> channels > 1 )
544+ {
545+ * p ++ = GetLCMSPixel (source_info ,GetPixelGreen (image ,q ));
546+ * p ++ = GetLCMSPixel (source_info ,GetPixelBlue (image ,q ));
547+ }
548+ if (source_info -> channels > 3 )
549+ * p ++ = GetLCMSPixel (source_info ,GetPixelBlack (image ,q ));
550+ q += GetPixelChannels (image );
551+ }
552+ cmsDoTransform (transform [id ],source_info -> pixels [id ],
553+ target_info -> pixels [id ],(unsigned int ) image -> columns );
554+ p = target_info -> pixels [id ];
555+ q -= GetPixelChannels (image )* image -> columns ;
556+ for (x = 0 ; x < (ssize_t ) image -> columns ; x ++ )
557+ {
558+ if (target_info -> channels == 1 )
559+ SetPixelGray (image ,SetLCMSPixel (target_info ,* p ),q );
560+ else
561+ SetPixelRed (image ,SetLCMSPixel (target_info ,* p ),q );
562+ p ++ ;
563+ if (target_info -> channels > 1 )
564+ {
565+ SetPixelGreen (image ,SetLCMSPixel (target_info ,* p ),q );
566+ p ++ ;
567+ SetPixelBlue (image ,SetLCMSPixel (target_info ,* p ),q );
568+ p ++ ;
569+ }
570+ if (target_info -> channels > 3 )
571+ {
572+ SetPixelBlack (image ,SetLCMSPixel (target_info ,* p ),q );
573+ p ++ ;
574+ }
575+ q += GetPixelChannels (image );
576+ }
577+ }
578+
579+ static void TransformQuantumPixels (const int id ,const Image * image ,
580+ const LCMSInfo * source_info ,const LCMSInfo * target_info ,
581+ const cmsHTRANSFORM * transform ,Quantum * q )
582+ {
583+ register Quantum
584+ * p ;
585+
586+ register ssize_t
587+ x ;
588+
589+ p = source_info -> pixels [id ];
590+ for (x = 0 ; x < (ssize_t ) image -> columns ; x ++ )
591+ {
592+ * p ++ = GetPixelRed (image ,q );
593+ if (source_info -> channels > 1 )
594+ {
595+ * p ++ = GetPixelGreen (image ,q );
596+ * p ++ = GetPixelBlue (image ,q );
597+ }
598+ if (source_info -> channels > 3 )
599+ * p ++ = GetLCMSPixel (source_info ,GetPixelBlack (image ,q ));
600+ q += GetPixelChannels (image );
601+ }
602+ cmsDoTransform (transform [id ],source_info -> pixels [id ],
603+ target_info -> pixels [id ],(unsigned int ) image -> columns );
604+ p = target_info -> pixels [id ];
605+ q -= GetPixelChannels (image )* image -> columns ;
606+ for (x = 0 ; x < (ssize_t ) image -> columns ; x ++ )
607+ {
608+ if (target_info -> channels == 1 )
609+ SetPixelGray (image ,* p ++ ,q );
610+ else
611+ SetPixelRed (image ,* p ++ ,q );
612+ if (target_info -> channels > 1 )
613+ {
614+ SetPixelGreen (image ,* p ++ ,q );
615+ SetPixelBlue (image ,* p ++ ,q );
616+ }
617+ if (target_info -> channels > 3 )
618+ SetPixelBlack (image ,* p ++ ,q );
619+ q += GetPixelChannels (image );
620+ }
621+ }
523622#endif
524623
525624static MagickBooleanType SetsRGBImageProfile (Image * image ,
@@ -815,105 +914,6 @@ static MagickBooleanType SetsRGBImageProfile(Image *image,
815914 return (status );
816915}
817916
818- static void TransformDoublePixels (const int id ,const Image * image ,
819- const LCMSInfo * source_info ,const LCMSInfo * target_info ,
820- const cmsHTRANSFORM * transform ,Quantum * q )
821- {
822- #define GetLCMSPixel (source_info ,pixel ) \
823- (source_info->scale*QuantumScale*(pixel)+source_info->translate)
824- #define SetLCMSPixel (target_info ,pixel ) \
825- ClampToQuantum(target_info->scale*QuantumRange*(pixel)+target_info->translate)
826-
827- register double
828- * p ;
829-
830- register ssize_t
831- x ;
832-
833- p = source_info -> pixels [id ];
834- for (x = 0 ; x < (ssize_t ) image -> columns ; x ++ )
835- {
836- * p ++ = GetLCMSPixel (source_info ,GetPixelRed (image ,q ));
837- if (source_info -> channels > 1 )
838- {
839- * p ++ = GetLCMSPixel (source_info ,GetPixelGreen (image ,q ));
840- * p ++ = GetLCMSPixel (source_info ,GetPixelBlue (image ,q ));
841- }
842- if (source_info -> channels > 3 )
843- * p ++ = GetLCMSPixel (source_info ,GetPixelBlack (image ,q ));
844- q += GetPixelChannels (image );
845- }
846- cmsDoTransform (transform [id ],source_info -> pixels [id ],
847- target_info -> pixels [id ],(unsigned int ) image -> columns );
848- p = target_info -> pixels [id ];
849- q -= GetPixelChannels (image )* image -> columns ;
850- for (x = 0 ; x < (ssize_t ) image -> columns ; x ++ )
851- {
852- if (target_info -> channels == 1 )
853- SetPixelGray (image ,SetLCMSPixel (target_info ,* p ),q );
854- else
855- SetPixelRed (image ,SetLCMSPixel (target_info ,* p ),q );
856- p ++ ;
857- if (target_info -> channels > 1 )
858- {
859- SetPixelGreen (image ,SetLCMSPixel (target_info ,* p ),q );
860- p ++ ;
861- SetPixelBlue (image ,SetLCMSPixel (target_info ,* p ),q );
862- p ++ ;
863- }
864- if (target_info -> channels > 3 )
865- {
866- SetPixelBlack (image ,SetLCMSPixel (target_info ,* p ),q );
867- p ++ ;
868- }
869- q += GetPixelChannels (image );
870- }
871- }
872-
873- static void TransformQuantumPixels (const int id ,const Image * image ,
874- const LCMSInfo * source_info ,const LCMSInfo * target_info ,
875- const cmsHTRANSFORM * transform ,Quantum * q )
876- {
877- register Quantum
878- * p ;
879-
880- register ssize_t
881- x ;
882-
883- p = source_info -> pixels [id ];
884- for (x = 0 ; x < (ssize_t ) image -> columns ; x ++ )
885- {
886- * p ++ = GetPixelRed (image ,q );
887- if (source_info -> channels > 1 )
888- {
889- * p ++ = GetPixelGreen (image ,q );
890- * p ++ = GetPixelBlue (image ,q );
891- }
892- if (source_info -> channels > 3 )
893- * p ++ = GetLCMSPixel (source_info ,GetPixelBlack (image ,q ));
894- q += GetPixelChannels (image );
895- }
896- cmsDoTransform (transform [id ],source_info -> pixels [id ],
897- target_info -> pixels [id ],(unsigned int ) image -> columns );
898- p = target_info -> pixels [id ];
899- q -= GetPixelChannels (image )* image -> columns ;
900- for (x = 0 ; x < (ssize_t ) image -> columns ; x ++ )
901- {
902- if (target_info -> channels == 1 )
903- SetPixelGray (image ,* p ++ ,q );
904- else
905- SetPixelRed (image ,* p ++ ,q );
906- if (target_info -> channels > 1 )
907- {
908- SetPixelGreen (image ,* p ++ ,q );
909- SetPixelBlue (image ,* p ++ ,q );
910- }
911- if (target_info -> channels > 3 )
912- SetPixelBlack (image ,* p ++ ,q );
913- q += GetPixelChannels (image );
914- }
915- }
916-
917917MagickExport MagickBooleanType ProfileImage (Image * image ,const char * name ,
918918 const void * datum ,const size_t length ,ExceptionInfo * exception )
919919{
0 commit comments