prepress.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "magick/studio.h"
00043 #include "magick/cache-view.h"
00044 #include "magick/exception.h"
00045 #include "magick/exception-private.h"
00046 #include "magick/hashmap.h"
00047 #include "magick/image.h"
00048 #include "magick/list.h"
00049 #include "magick/memory_.h"
00050 #include "magick/prepress.h"
00051 #include "magick/registry.h"
00052 #include "magick/semaphore.h"
00053 #include "magick/splay-tree.h"
00054 #include "magick/string_.h"
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 MagickExport double GetImageTotalInkDensity(Image *image)
00081 {
00082 double
00083 total_ink_density;
00084
00085 ExceptionInfo
00086 *exception;
00087
00088 long
00089 y;
00090
00091 MagickBooleanType
00092 status;
00093
00094 ViewInfo
00095 *image_view;
00096
00097 assert(image != (Image *) NULL);
00098 if (image->debug != MagickFalse)
00099 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
00100 assert(image->signature == MagickSignature);
00101 if (image->colorspace != CMYKColorspace)
00102 {
00103 (void) ThrowMagickException(&image->exception,GetMagickModule(),
00104 ImageError,"ColorSeparatedImageRequired","`%s'",image->filename);
00105 return(0.0);
00106 }
00107 status=MagickTrue;
00108 total_ink_density=0.0;
00109 exception=(&image->exception);
00110 image_view=AcquireCacheView(image);
00111 #if defined(MAGICKCORE_OPENMP_SUPPORT)
00112 #pragma omp parallel for schedule(dynamic,8) shared(status)
00113 #endif
00114 for (y=0; y < (long) image->rows; y++)
00115 {
00116 double
00117 density;
00118
00119 register const IndexPacket
00120 *indexes;
00121
00122 register const PixelPacket
00123 *p;
00124
00125 register long
00126 x;
00127
00128 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
00129 if (p == (const PixelPacket *) NULL)
00130 {
00131 status=MagickFalse;
00132 continue;
00133 }
00134 indexes=GetCacheViewVirtualIndexQueue(image_view);
00135 for (x=0; x < (long) image->columns; x++)
00136 {
00137 density=(double) p->red+p->green+p->blue+indexes[x];
00138 if (density > total_ink_density)
00139 #if defined(MAGICKCORE_OPENMP_SUPPORT)
00140 #pragma omp critical
00141 #endif
00142 {
00143 if (density > total_ink_density)
00144 total_ink_density=density;
00145 }
00146 p++;
00147 }
00148 }
00149 image_view=DestroyCacheView(image_view);
00150 if (status == MagickFalse)
00151 total_ink_density=0.0;
00152 return(total_ink_density);
00153 }