本文整理汇总了C++中ClampToQuantum函数的典型用法代码示例。如果您正苦于以下问题:C++ ClampToQuantum函数的具体用法?C++ ClampToQuantum怎么用?C++ ClampToQuantum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ClampToQuantum函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ConvertHSLToRGB
MagickExport void ConvertHSLToRGB(const double hue,const double saturation,
const double lightness,Quantum *red,Quantum *green,Quantum *blue)
{
MagickRealType
b,
g,
r,
m1,
m2;
/*
Convert HSL to RGB colorspace.
*/
assert(red != (Quantum *) NULL);
assert(green != (Quantum *) NULL);
assert(blue != (Quantum *) NULL);
if (saturation == 0)
{
*red=ClampToQuantum((MagickRealType) QuantumRange*lightness);
*green=(*red);
*blue=(*red);
return;
}
if (lightness < 0.5)
m2=lightness*(saturation+1.0);
else
m2=(lightness+saturation)-(lightness*saturation);
m1=2.0*lightness-m2;
r=ConvertHueToRGB(m1,m2,hue+1.0/3.0);
g=ConvertHueToRGB(m1,m2,hue);
b=ConvertHueToRGB(m1,m2,hue-1.0/3.0);
*red=ClampToQuantum((MagickRealType) QuantumRange*r);
*green=ClampToQuantum((MagickRealType) QuantumRange*g);
*blue=ClampToQuantum((MagickRealType) QuantumRange*b);
}
开发者ID:271845221,项目名称:Android-ImageMagick,代码行数:35,代码来源:gem.c
示例2: sanpera_magick_pixel_from_doubles
void sanpera_magick_pixel_from_doubles(MagickPixelPacket *pixel, double in[4]) {
SetPixelRed(pixel, ClampToQuantum(in[0] * QuantumRange));
SetPixelGreen(pixel, ClampToQuantum(in[1] * QuantumRange));
SetPixelBlue(pixel, ClampToQuantum(in[2] * QuantumRange));
// Distinct from "opacity", which treats 0 as opaque
SetPixelAlpha(pixel, ClampToQuantum(in[3] * QuantumRange));
}
开发者ID:harvimt,项目名称:sanpera,代码行数:7,代码来源:_api.c
示例3: sanpera_magick_pixel_from_doubles_channel
void sanpera_magick_pixel_from_doubles_channel(
MagickPixelPacket *pixel, double in[4], ChannelType channels)
{
if (channels & RedChannel)
SetPixelRed(pixel, ClampToQuantum(in[0] * QuantumRange));
if (channels & GreenChannel)
SetPixelGreen(pixel, ClampToQuantum(in[1] * QuantumRange));
if (channels & BlueChannel)
SetPixelBlue(pixel, ClampToQuantum(in[2] * QuantumRange));
// Distinct from "opacity", which treats 0 as opaque
if (channels & AlphaChannel)
SetPixelAlpha(pixel, ClampToQuantum(in[3] * QuantumRange));
}
开发者ID:harvimt,项目名称:sanpera,代码行数:13,代码来源:_api.c
示例4: GetOneCacheViewVirtualPixel
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% G e t O n e C a c h e V i e w V i r t u a l P i x e l %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
% location. The image background color is returned if an error occurs. If
% you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
%
% The format of the GetOneCacheViewVirtualPixel method is:
%
% MagickBooleanType GetOneCacheViewVirtualPixel(
% const CacheView *cache_view,const ssize_t x,const ssize_t y,
% Quantum *pixel,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o cache_view: the cache view.
%
% o x,y: These values define the offset of the pixel.
%
% o pixel: return a pixel at the specified (x,y) location.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
ExceptionInfo *exception)
{
const int
id = GetOpenMPThreadId();
register const Quantum
*magick_restrict p;
register ssize_t
i;
assert(cache_view != (CacheView *) NULL);
assert(cache_view->signature == MagickCoreSignature);
assert(id < (int) cache_view->number_threads);
(void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
p=GetVirtualPixelsFromNexus(cache_view->image,
cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
exception);
if (p == (const Quantum *) NULL)
{
PixelInfo
background_color;
background_color=cache_view->image->background_color;
pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
return(MagickFalse);
}
for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
{
PixelChannel channel=GetPixelChannelChannel(cache_view->image,i);
pixel[channel]=p[i];
}
return(MagickTrue);
}
开发者ID:DINKIN,项目名称:ImageMagick,代码行数:72,代码来源:cache-view.c
示例5: PrintChannelStatistics
static int PrintChannelStatistics(FILE *file,const ChannelType channel,
const char *name,const double scale,
const ChannelStatistics *channel_statistics)
{
#define StatisticsFormat " %s:\n min: " QuantumFormat \
" (%g)\n max: " QuantumFormat " (%g)\n" \
" mean: %g (%g)\n standard deviation: %g (%g)\n" \
" kurtosis: %g\n skewness: %g\n"
int
status;
if (channel == AlphaChannel)
{
status=fprintf(file,StatisticsFormat,name,ClampToQuantum(scale*
(QuantumRange-channel_statistics[channel].maxima)),
(QuantumRange-channel_statistics[channel].maxima)/(double) QuantumRange,
ClampToQuantum(scale*(QuantumRange-channel_statistics[channel].minima)),
(QuantumRange-channel_statistics[channel].minima)/(double) QuantumRange,
scale*(QuantumRange-channel_statistics[channel].mean),(QuantumRange-
channel_statistics[channel].mean)/(double) QuantumRange,scale*
channel_statistics[channel].standard_deviation,
channel_statistics[channel].standard_deviation/(double) QuantumRange,
channel_statistics[channel].kurtosis,
channel_statistics[channel].skewness);
return(status);
}
status=fprintf(file,StatisticsFormat,name,ClampToQuantum(scale*
channel_statistics[channel].minima),channel_statistics[channel].minima/
(double) QuantumRange,ClampToQuantum(scale*
channel_statistics[channel].maxima),channel_statistics[channel].maxima/
(double) QuantumRange,scale*channel_statistics[channel].mean,
channel_statistics[channel].mean/(double) QuantumRange,scale*
channel_statistics[channel].standard_deviation,
channel_statistics[channel].standard_deviation/(double) QuantumRange,
channel_statistics[channel].kurtosis,channel_statistics[channel].skewness);
return(status);
}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:38,代码来源:identify.c
示例6: PrintChannelStatistics
static ssize_t PrintChannelStatistics(FILE *file,const PixelChannel channel,
const char *name,const double scale,
const ChannelStatistics *channel_statistics)
{
#define StatisticsFormat " %s:\n min: " QuantumFormat \
" (%g)\n max: " QuantumFormat " (%g)\n" \
" mean: %g (%g)\n standard deviation: %g (%g)\n" \
" kurtosis: %g\n skewness: %g\n"
ssize_t
n;
n=FormatLocaleFile(file,StatisticsFormat,name,ClampToQuantum(scale*
channel_statistics[channel].minima),channel_statistics[channel].minima/
(double) QuantumRange,ClampToQuantum(scale*
channel_statistics[channel].maxima),channel_statistics[channel].maxima/
(double) QuantumRange,scale*channel_statistics[channel].mean,
channel_statistics[channel].mean/(double) QuantumRange,scale*
channel_statistics[channel].standard_deviation,
channel_statistics[channel].standard_deviation/(double) QuantumRange,
channel_statistics[channel].kurtosis,channel_statistics[channel].skewness);
return(n);
}
开发者ID:Ladeira,项目名称:ImageMagick,代码行数:23,代码来源:identify.c
示例7: ConvertHWBToRGB
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% C o n v e r t H W B T o R G B %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ConvertHWBToRGB() transforms a (hue, whiteness, blackness) to a (red, green,
% blue) triple.
%
% The format of the ConvertHWBToRGBImage method is:
%
% void ConvertHWBToRGB(const double hue,const double whiteness,
% const double blackness,Quantum *red,Quantum *green,Quantum *blue)
%
% A description of each parameter follows:
%
% o hue, whiteness, blackness: A double value representing a
% component of the HWB color space.
%
% o red, green, blue: A pointer to a pixel component of type Quantum.
%
*/
MagickExport void ConvertHWBToRGB(const double hue,const double whiteness,
const double blackness,Quantum *red,Quantum *green,Quantum *blue)
{
MagickRealType
b,
f,
g,
n,
r,
v;
register ssize_t
i;
/*
Convert HWB to RGB colorspace.
*/
assert(red != (Quantum *) NULL);
assert(green != (Quantum *) NULL);
assert(blue != (Quantum *) NULL);
v=1.0-blackness;
if (hue == 0.0)
{
*red=ClampToQuantum((MagickRealType) QuantumRange*v);
*green=ClampToQuantum((MagickRealType) QuantumRange*v);
*blue=ClampToQuantum((MagickRealType) QuantumRange*v);
return;
}
i=(ssize_t) floor(6.0*hue);
f=6.0*hue-i;
if ((i & 0x01) != 0)
f=1.0-f;
n=whiteness+f*(v-whiteness); /* linear interpolation */
switch (i)
{
default:
case 6:
case 0: r=v; g=n; b=whiteness; break;
case 1: r=n; g=v; b=whiteness; break;
case 2: r=whiteness; g=v; b=n; break;
case 3: r=whiteness; g=n; b=v; break;
case 4: r=n; g=whiteness; b=v; break;
case 5: r=v; g=whiteness; b=n; break;
}
*red=ClampToQuantum((MagickRealType) QuantumRange*r);
*green=ClampToQuantum((MagickRealType) QuantumRange*g);
*blue=ClampToQuantum((MagickRealType) QuantumRange*b);
}
开发者ID:271845221,项目名称:Android-ImageMagick,代码行数:75,代码来源:gem.c
示例8: assert
//.........这里部分代码省略.........
int
max_x,
max_y,
min_x,
min_y;
MagickBooleanType
status;
register ssize_t
x;
register Quantum
*q;
ssize_t
y;
/*
Open image.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
read_info=CloneImageInfo(image_info);
if (IsPathAccessible(read_info->filename) == MagickFalse)
{
(void) AcquireUniqueFilename(read_info->filename);
(void) ImageToFile(image,read_info->filename,exception);
}
file=ImfOpenInputFile(read_info->filename);
if (file == (ImfInputFile *) NULL)
{
ThrowFileException(exception,BlobError,"UnableToOpenBlob",
ImfErrorMessage());
read_info=DestroyImageInfo(read_info);
return((Image *) NULL);
}
hdr_info=ImfInputHeader(file);
ImfHeaderDataWindow(hdr_info,&min_x,&min_y,&max_x,&max_y);
image->columns=max_x-min_x+1UL;
image->rows=max_y-min_y+1UL;
image->matte=MagickTrue;
if (image_info->ping != MagickFalse)
{
(void) ImfCloseInputFile(file);
if (LocaleCompare(image_info->filename,read_info->filename) != 0)
(void) RelinquishUniqueFileResource(read_info->filename);
read_info=DestroyImageInfo(read_info);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
scanline=(ImfRgba *) AcquireQuantumMemory(image->columns,sizeof(*scanline));
if (scanline == (ImfRgba *) NULL)
{
(void) ImfCloseInputFile(file);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
ImfInputSetFrameBuffer(file,scanline-min_x-image->columns*(min_y+y),1,
image->columns);
ImfInputReadPixels(file,min_y+y,min_y+y);
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(image,ClampToQuantum((MagickRealType) QuantumRange*
ImfHalfToFloat(scanline[x].r)),q);
SetPixelGreen(image,ClampToQuantum((MagickRealType) QuantumRange*
ImfHalfToFloat(scanline[x].g)),q);
SetPixelBlue(image,ClampToQuantum((MagickRealType) QuantumRange*
ImfHalfToFloat(scanline[x].b)),q);
SetPixelAlpha(image,ClampToQuantum((MagickRealType) QuantumRange*
ImfHalfToFloat(scanline[x].a)),q);
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
scanline=(ImfRgba *) RelinquishMagickMemory(scanline);
(void) ImfCloseInputFile(file);
if (LocaleCompare(image_info->filename,read_info->filename) != 0)
(void) RelinquishUniqueFileResource(read_info->filename);
read_info=DestroyImageInfo(read_info);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
开发者ID:ChaseReid,项目名称:ImageMagick,代码行数:101,代码来源:exr.c
示例9: ConvertHCLToRGB
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% C o n v e r t H C L T o R G B %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ConvertHCLToRGB() transforms a (hue, chroma, luma) to a (red, green,
% blue) triple.
%
% The format of the ConvertHCLToRGBImage method is:
%
% void ConvertHCLToRGB(const double hue,const double chroma,
% const double luma,Quantum *red,Quantum *green,Quantum *blue)
%
% A description of each parameter follows:
%
% o hue, chroma, luma: A double value representing a
% component of the HCL color space.
%
% o red, green, blue: A pointer to a pixel component of type Quantum.
%
*/
MagickExport void ConvertHCLToRGB(const double hue,const double chroma,
const double luma,Quantum *red,Quantum *green,Quantum *blue)
{
double
b,
c,
g,
h,
m,
r,
x;
/*
Convert HCL to RGB colorspace.
*/
assert(red != (Quantum *) NULL);
assert(green != (Quantum *) NULL);
assert(blue != (Quantum *) NULL);
h=6.0*hue;
c=chroma;
x=c*(1.0-fabs(fmod(h,2.0)-1.0));
r=0.0;
g=0.0;
b=0.0;
if ((0.0 <= h) && (h < 1.0))
{
r=c;
g=x;
}
else
if ((1.0 <= h) && (h < 2.0))
{
r=x;
g=c;
}
else
if ((2.0 <= h) && (h < 3.0))
{
g=c;
b=x;
}
else
if ((3.0 <= h) && (h < 4.0))
{
g=x;
b=c;
}
else
if ((4.0 <= h) && (h < 5.0))
{
r=x;
b=c;
}
else
if ((5.0 <= h) && (h < 6.0))
{
r=c;
b=x;
}
m=luma-(0.298839f*r+0.586811f*g+0.114350f*b);
*red=ClampToQuantum(QuantumRange*(r+m));
*green=ClampToQuantum(QuantumRange*(g+m));
*blue=ClampToQuantum(QuantumRange*(b+m));
}
开发者ID:MaximOrlovsky,项目名称:unix-toolbox.js-imagemagick,代码行数:91,代码来源:gem.c
示例10: ForwardFourier
static MagickBooleanType ForwardFourier(const FourierInfo *fourier_info,
Image *image,double *magnitude,double *phase,ExceptionInfo *exception)
{
CacheView
*magnitude_view,
*phase_view;
double
*magnitude_source,
*phase_source;
Image
*magnitude_image,
*phase_image;
MagickBooleanType
status;
register IndexPacket
*indexes;
register ssize_t
x;
register PixelPacket
*q;
ssize_t
i,
y;
magnitude_image=GetFirstImageInList(image);
phase_image=GetNextImageInList(image);
if (phase_image == (Image *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),ImageError,
"ImageSequenceRequired","`%s'",image->filename);
return(MagickFalse);
}
/*
Create "Fourier Transform" image from constituent arrays.
*/
magnitude_source=(double *) AcquireQuantumMemory((size_t)
fourier_info->height,fourier_info->width*sizeof(*magnitude_source));
if (magnitude_source == (double *) NULL)
return(MagickFalse);
(void) ResetMagickMemory(magnitude_source,0,fourier_info->height*
fourier_info->width*sizeof(*magnitude_source));
phase_source=(double *) AcquireQuantumMemory((size_t) fourier_info->height,
fourier_info->width*sizeof(*phase_source));
if (phase_source == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
magnitude_source=(double *) RelinquishMagickMemory(magnitude_source);
return(MagickFalse);
}
status=ForwardQuadrantSwap(fourier_info->height,fourier_info->height,
magnitude,magnitude_source);
if (status != MagickFalse)
status=ForwardQuadrantSwap(fourier_info->height,fourier_info->height,phase,
phase_source);
CorrectPhaseLHS(fourier_info->height,fourier_info->height,phase_source);
if (fourier_info->modulus != MagickFalse)
{
i=0L;
for (y=0L; y < (ssize_t) fourier_info->height; y++)
for (x=0L; x < (ssize_t) fourier_info->width; x++)
{
phase_source[i]/=(2.0*MagickPI);
phase_source[i]+=0.5;
i++;
}
}
magnitude_view=AcquireAuthenticCacheView(magnitude_image,exception);
i=0L;
for (y=0L; y < (ssize_t) fourier_info->height; y++)
{
q=GetCacheViewAuthenticPixels(magnitude_view,0L,y,fourier_info->height,1UL,
exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetCacheViewAuthenticIndexQueue(magnitude_view);
for (x=0L; x < (ssize_t) fourier_info->width; x++)
{
switch (fourier_info->channel)
{
case RedChannel:
default:
{
SetPixelRed(q,ClampToQuantum(QuantumRange*
magnitude_source[i]));
break;
}
case GreenChannel:
{
SetPixelGreen(q,ClampToQuantum(QuantumRange*
magnitude_source[i]));
break;
}
//.........这里部分代码省略.........
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:101,代码来源:fourier.c
示例11: ReadHALDImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d H A L D I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadHALDImage() creates a Hald color lookup table image and returns it. It
% allocates the memory necessary for the new Image structure and returns a
% pointer to the new image.
%
% The format of the ReadHALDImage method is:
%
% Image *ReadHALDImage(const ImageInfo *image_info,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image_info: the image info.
%
% o exception: return any errors or warnings in this structure.
%
*/
static Image *ReadHALDImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
Image
*image;
MagickBooleanType
status;
size_t
cube_size,
level;
ssize_t
y;
/*
Create HALD color lookup table image.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
image=AcquireImage(image_info);
level=0;
if (*image_info->filename != '\0')
level=StringToUnsignedLong(image_info->filename);
if (level < 2)
level=8;
status=MagickTrue;
cube_size=level*level;
image->columns=(size_t) (level*cube_size);
image->rows=(size_t) (level*cube_size);
for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) level)
{
ssize_t
blue,
green,
red;
register PixelPacket
*restrict q;
if (status == MagickFalse)
continue;
q=QueueAuthenticPixels(image,0,y,image->columns,(size_t) level,
exception);
if (q == (PixelPacket *) NULL)
{
status=MagickFalse;
continue;
}
blue=y/(ssize_t) level;
for (green=0; green < (ssize_t) cube_size; green++)
{
for (red=0; red < (ssize_t) cube_size; red++)
{
SetPixelRed(q,ClampToQuantum(QuantumRange*red/
(cube_size-1.0)));
SetPixelGreen(q,ClampToQuantum(QuantumRange*green/
(cube_size-1.0)));
SetPixelBlue(q,ClampToQuantum(QuantumRange*blue/
(cube_size-1.0)));
SetPixelOpacity(q,OpaqueOpacity);
q++;
}
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
status=MagickFalse;
}
//.........这里部分代码省略.........
开发者ID:271845221,项目名称:Android-ImageMagick,代码行数:101,代码来源:hald.c
示例12: InverseFourierTransform
static MagickBooleanType InverseFourierTransform(FourierInfo *fourier_info,
fftw_complex *fourier,Image *image,ExceptionInfo *exception)
{
CacheView
*image_view;
double
*source;
fftw_plan
fftw_c2r_plan;
register IndexPacket
*indexes;
register PixelPacket
*q;
register ssize_t
i,
x;
ssize_t
y;
source=(double *) AcquireQuantumMemory((size_t) fourier_info->height,
fourier_info->width*sizeof(*source));
if (source == (double *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
return(MagickFalse);
}
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp critical (MagickCore_InverseFourierTransform)
#endif
{
fftw_c2r_plan=fftw_plan_dft_c2r_2d(fourier_info->width,fourier_info->height,
fourier,source,FFTW_ESTIMATE);
fftw_execute(fftw_c2r_plan);
fftw_destroy_plan(fftw_c2r_plan);
}
i=0L;
image_view=AcquireAuthenticCacheView(image,exception);
for (y=0L; y < (ssize_t) fourier_info->height; y++)
{
if (y >= (ssize_t) image->rows)
break;
q=GetCacheViewAuthenticPixels(image_view,0L,y,fourier_info->width >
image->columns ? image->columns : fourier_info->width,1UL,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetCacheViewAuthenticIndexQueue(image_view);
for (x=0L; x < (ssize_t) fourier_info->width; x++)
{
if (x < (ssize_t) image->columns)
switch (fourier_info->channel)
{
case RedChannel:
default:
{
SetPixelRed(q,ClampToQuantum(QuantumRange*source[i]));
break;
}
case GreenChannel:
{
SetPixelGreen(q,ClampToQuantum(QuantumRange*source[i]));
break;
}
case BlueChannel:
{
SetPixelBlue(q,ClampToQuantum(QuantumRange*source[i]));
break;
}
case OpacityChannel:
{
SetPixelOpacity(q,ClampToQuantum(QuantumRange*source[i]));
break;
}
case IndexChannel:
{
SetPixelIndex(indexes+x,ClampToQuantum(QuantumRange*source[i]));
break;
}
case GrayChannels:
{
SetPixelGray(q,ClampToQuantum(QuantumRange*source[i]));
break;
}
}
i++;
q++;
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
break;
}
image_view=DestroyCacheView(image_view);
source=(double *) RelinquishMagickMemory(source);
return(MagickTrue);
}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:100,代码来源:fourier.c
示例13: CombineImages
//.........这里部分代码省略.........
*next;
PixelPacket
*pixels;
register const PixelPacket
*restrict p;
register PixelPacket
*restrict q;
register ssize_t
x;
if (status == MagickFalse)
continue;
pixels=GetCacheViewAuthenticPixels(combine_view,0,y,combine_image->columns,
1,exception);
if (pixels == (PixelPacket *) NULL)
{
status=MagickFalse;
continue;
}
next=image;
if (((channel & RedChannel) != 0) && (next != (Image *) NULL))
{
image_view=AcquireVirtualCacheView(next,exception);
p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
if (p == (const PixelPacket *) NULL)
continue;
q=pixels;
for (x=0; x < (ssize_t) combine_image->columns; x++)
{
SetPixelRed(q,ClampToQuantum(GetPixelIntensity(image,p)));
p++;
q++;
}
image_view=DestroyCacheView(image_view);
next=GetNextImageInList(next);
}
if (((channel & GreenChannel) != 0) && (next != (Image *) NULL))
{
image_view=AcquireVirtualCacheView(next,exception);
p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
if (p == (const PixelPacket *) NULL)
continue;
q=pixels;
for (x=0; x < (ssize_t) combine_image->columns; x++)
{
SetPixelGreen(q,ClampToQuantum(GetPixelIntensity(image,p)));
p++;
q++;
}
image_view=DestroyCacheView(image_view);
next=GetNextImageInList(next);
}
if (((channel & BlueChannel) != 0) && (next != (Image *) NULL))
{
image_view=AcquireVirtualCacheView(next,exception);
p=GetCacheViewVirtualPixels(image_view,0,y,next->columns,1,exception);
if (p == (const PixelPacket *) NULL)
continue;
q=pixels;
for (x=0; x < (ssize_t) combine_image->columns; x++)
{
SetPixelBlue(q,ClampToQuantum(GetPixelIntensity(image,p)));
开发者ID:abzolute0,项目名称:Ruby_Blog,代码行数:67,代码来源:channel.c
示例14: SeparateImageChannel
//.........这里部分代码省略.........
{
case RedChannel:
{
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelGreen(q,GetPixelRed(q));
SetPixelBlue(q,GetPixelRed(q));
q++;
}
break;
}
case GreenChannel:
{
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(q,GetPixelGreen(q));
SetPixelBlue(q,GetPixelGreen(q));
q++;
}
break;
}
case BlueChannel:
{
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(q,GetPixelBlue(q));
SetPixelGreen(q,GetPixelBlue(q));
q++;
}
break;
}
case OpacityChannel:
{
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(q,GetPixelOpacity(q));
SetPixelGreen(q,GetPixelOpacity(q));
SetPixelBlue(q,GetPixelOpacity(q));
q++;
}
break;
}
case BlackChannel:
{
if ((image->storage_class != PseudoClass) &&
(image->colorspace != CMYKColorspace))
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(q,GetPixelIndex(indexes+x));
SetPixelGreen(q,GetPixelIndex(indexes+x));
SetPixelBlue(q,GetPixelIndex(indexes+x));
q++;
}
break;
}
case TrueAlphaChannel:
{
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(q,GetPixelAlpha(q));
SetPixelGreen(q,GetPixelAlpha(q));
SetPixelBlue(q,GetPixelAlpha(q));
q++;
}
break;
}
case GrayChannels:
{
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelAlpha(q,ClampToQuantum(GetPixelIntensity(image,q)));
q++;
}
break;
}
default:
break;
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
MagickBooleanType
proceed;
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp critical (MagickCore_SeparateImageChannel)
#endif
proceed=SetImageProgress(image,SeparateImageTag,progress++,image->rows);
if (proceed == MagickFalse)
status=MagickFalse;
}
}
image_view=DestroyCacheView(image_view);
if (channel != GrayChannels)
image->matte=MagickFalse;
(void) SetImageColorspace(image,GRAYColorspace);
return(status);
}
开发者ID:abzolute0,项目名称:Ruby_Blog,代码行数:101,代码来源:channel.c
示例15: SetImageAlphaChannel
MagickExport MagickBooleanType SetImageAlphaChannel(Image *image,
const AlphaChannelOption alpha_type,ExceptionInfo *exception)
{
CacheView
*image_view;
MagickBooleanType
status;
ssize_t
y;
assert(image != (Image *) NULL);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(image->signature == MagickSignature);
status=MagickTrue;
switch (alpha_type)
{
case ActivateAlphaChannel:
{
image->alpha_trait=BlendPixelTrait;
break;
}
case AssociateAlphaChannel:
{
/*
Associate alpha.
*/
status=SetImageStorageClass(image,DirectClass,exception);
if (status == MagickFalse)
break;
image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(status) \
magick_threads(image,image,image->rows,1)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
register Quantum
*restrict q;
register ssize_t
x;
if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
}
for (x=0; x < (ssize_t) image->columns; x++)
{
double
Sa;
register ssize_t
i;
if (GetPixelReadMask(image,q) == 0)
{
q+=GetPixelChannels(image);
continue;
}
Sa=QuantumScale*GetPixelAlpha(image,q);
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
PixelChannel channel=GetPixelChannelChannel(image,i);
PixelTrait traits=GetPixelChannelTraits(image,channel);
if ((traits & UpdatePixelTrait) == 0)
continue;
q[i]=ClampToQuantum(Sa*q[i]);
}
q+=GetPixelChannels(image);
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
status=MagickFalse;
}
image_view=DestroyCacheView(image_view);
image->alpha_trait=CopyPixelTrait;
return(status);
}
case BackgroundAlphaChannel:
{
/*
Set transparent pixels to background color.
*/
if (image->alpha_trait != BlendPixelTrait)
break;
status=SetImageStorageClass(image,DirectClass,exception);
if (status == MagickFalse)
break;
image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static,4) shared(status) \
magick_threads(image,image,image->rows,1)
#endif
//.........这里部分代码省略.........
开发者ID:saitoha,项目名称:ImageMagick-V7-SIXEL,代码行数:101,代码来源:channel.c
示例16: ReadHDRImage
//.........这里部分代码省略.........
if (image->compression != RLECompression)
{
count=ReadBlob(image,4*image->columns*sizeof(*pixels),pixels);
if (count != (ssize_t) (4*image->columns*sizeof(*pixels)))
break;
}
else
{
count=ReadBlob(image,4*sizeof(*pixel),pixel);
if (count != 4)
break;
if ((size_t) ((((size_t) pixel[2]) << 8) | pixel[3]) != image->columns)
{
(void) memcpy(pixels,pixel,4*sizeof(*pixel));
(void) ReadBlob(image,4*(image->columns-1)*sizeof(*pixels),pixels+4);
image->compression=NoCompression;
}
else
{
p=pixels;
for (i=0; i < 4; i++)
{
end=&pixels[(i+1)*image->columns];
while (p < end)
{
count=ReadBlob(image,2*sizeof(*pixel),pixel);
if (count < 1)
break;
if (pixel[0] > 128)
{
count=(ssize_t) pixel[0]-128;
if ((count == 0) || (count > (ssize_t) (end-p)))
break;
while (count-- > 0)
*p++=pixel[1];
}
else
{
count=(ssize_t) pixel[0];
if ((count == 0) || (count > (ssize_t) (end-p)))
break;
*p++=pixel[1];
if (--count > 0)
{
count=ReadBlob(image,(size_t) count*sizeof(*p),p);
if (count < 1)
break;
p+=count;
}
}
}
}
}
}
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
i=0;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (image->compression == RLECompression)
{
pixel[0]=pixels[x];
pixel[1]=pixels[x+image->columns];
pixel[2]=pixels[x+2*image->columns];
pixel[3]=pixels[x+3*image->columns];
}
else
{
pixel[0]=pixels[i++];
pixel[1]=pixels[i++];
pixel[2]=pixels[i++];
pixel[3]=pixels[i++];
}
SetPixelRed(q,0);
SetPixelGreen(q,0);
SetPixelBlue(q,0);
if (pixel[3] != 0)
{
gamma=pow(2.0,pixel[3]-(128.0+8.0));
SetPixelRed(q,ClampToQuantum(QuantumRange*gamma*pixel[0]));
SetPixelGreen(q,ClampToQuantum(QuantumRange*gamma*pixel[1]));
SetPixelBlue(q,ClampToQuantum(QuantumRange*gamma*pixel[2]));
}
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
开发者ID:INT2208-ST,项目名称:MyFriend,代码行数:101,代码来源:hdr.c
示例17: FlattenPixelInfo
static inline void FlattenPixelInfo(const Image *image,const PixelInfo *p,
const double alpha,const Quantum *q,const double beta,
Quantum *composite)
{
double
Da,
gamma,
Sa;
register ssize_t
i;
/*
Compose pixel p over pixel q with the given alpha.
*/
Sa=QuantumScale*alpha;
Da=QuantumScale*beta,
gamma=Sa*(-Da)+Sa+Da;
gamma=PerceptibleReciprocal(gamma);
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
PixelChannel channel=GetPixelChannelChannel(image,i);
PixelTrait traits=GetPixelChannelTraits(image,channel);
if (traits == UndefinedPixelTrait)
continue;
switch (channel)
{
case RedPixelChannel:
{
composite[i]=ClampToQuantum(gamma*MagickOver_((double) q[i],beta,
(double) p->red,alpha));
break;
}
case GreenPixelChannel:
{
composite[i]=ClampToQuantum(gamma*MagickOver_((double) q[i],beta,
(double) p->green,alpha));
break;
}
case BluePixelChannel:
{
composite[i]=ClampToQuantum(gamma*MagickOver_((double) q[i],beta,
(double) p->blue,alpha));
break;
}
case BlackPixelChannel:
{
composite[i]=ClampToQuantum(gamma*MagickOver_((double) q[i],beta,
(double) p->black,alpha));
break;
}
case AlphaPixelChannel:
{
composite[i]=ClampToQuantum(QuantumRange*(Sa*(-Da)+Sa+Da));
break;
}
default:
break;
}
}
}
开发者ID:saitoha,项目名称:ImageMagick-V7-SIXEL,代码行数:61,代码来源:channel.c
示例18: assert
//.........这里部分代码省略.........
}
case ExchangeChannelOp:
case TransferChannelOp:
{
i=ParsePixelChannelOption(token);
if (i < 0)
{
(void) ThrowMagickException(exception,GetMagickModule(),OptionError,
"UnrecognizedChannelType","`%s'",token);
destination_image=DestroyImageList(destination_image);
return(destination_image);
}
destination_channel=(PixelChannel) i;
switch (destination_channel)
{
case RedPixelChannel:
case GreenPixelChannel:
case BluePixelChannel:
case BlackPixelChannel:
case IndexPixelChannel:
break;
case AlphaPixelChannel:
{
destination_image->alpha_trait=BlendPixelTrait;
break;
}
case ReadMaskPixelChannel:
{
destination_image->read_mask=MagickTrue;
break;
}
case WriteMaskPixelChannel:
{
destination_image->write_mask=MagickTrue;
break;
}
case MetaPix
|
请发表评论