本文整理汇总了C++中SyncImage函数的典型用法代码示例。如果您正苦于以下问题:C++ SyncImage函数的具体用法?C++ SyncImage怎么用?C++ SyncImage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SyncImage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Current
void IconDes::Undo()
{
if(!IsCurrent())
return;
Slot& c = Current();
Vector<Image> undo = UnpackImlData(c.undo);
if(undo.GetCount() == 0)
return;
Vector<Image> redo = UnpackImlData(c.redo);
redo.Add(c.image);
c.image = undo.Pop();
c.supersampling = sRemoveSsFlag(c.image);
c.undo = PackImlData(undo);
c.redo = PackImlData(redo);
SyncImage();
SetBar();
}
示例2: ReadMACImage
//.........这里部分代码省略.........
{
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
status=SetImageExtent(image,image->columns,image->rows);
if (status == MagickFalse)
{
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
/*
Convert MAC raster image to pixel packets.
*/
length=(image->columns+7)/8;
pixels=(unsigned char *) AcquireQuantumMemory(length+1,sizeof(*pixels));
if (pixels == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
p=pixels;
offset=0;
for (y=0; y < (ssize_t) image->rows; )
{
count=(unsigned char) ReadBlobByte(image);
if (EOFBlob(image) != MagickFalse)
break;
if ((count <= 0) || (count >= 128))
{
byte=(unsigned char) (~ReadBlobByte(image));
count=(~count)+2;
while (count != 0)
{
*p++=byte;
offset++;
count--;
if (offset >= (ssize_t) length)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
p=pixels;
bit=0;
byte=0;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (bit == 0)
byte=(*p++);
SetPixelIndex(indexes+x,((byte & 0x80) != 0 ? 0x01 : 0x00));
bit++;
byte<<=1;
if (bit == 8)
bit=0;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
offset=0;
p=pixels;
y++;
}
}
continue;
}
count++;
while (count != 0)
{
byte=(unsigned char) (~ReadBlobByte(image));
*p++=byte;
offset++;
count--;
if (offset >= (ssize_t) length)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
p=pixels;
bit=0;
byte=0;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (bit == 0)
byte=(*p++);
SetPixelIndex(indexes+x,((byte & 0x80) != 0 ? 0x01 : 0x00));
bit++;
byte<<=1;
if (bit == 8)
bit=0;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
offset=0;
p=pixels;
y++;
}
}
}
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
(void) SyncImage(image);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
示例3: SetSelect
void IconDes::Reset()
{
SetSelect(255);
SyncImage();
}
示例4: ReadTIMImage
//.........这里部分代码省略.........
}
case 16:
{
/*
Convert DirectColor scanline.
*/
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=tim_pixels+y*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
word=(*p++);
word|=(*p++ << 8);
SetPixelBlue(image,ScaleCharToQuantum(ScaleColor5to8(
(1UL*word >> 10) & 0x1f)),q);
SetPixelGreen(image,ScaleCharToQuantum(ScaleColor5to8(
(1UL*word >> 5) & 0x1f)),q);
SetPixelRed(image,ScaleCharToQuantum(ScaleColor5to8(
(1UL*word >> 0) & 0x1f)),q);
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
break;
}
case 24:
{
/*
Convert DirectColor scanline.
*/
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=tim_pixels+y*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(image,ScaleCharToQuantum(*p++),q);
SetPixelGreen(image,ScaleCharToQuantum(*p++),q);
SetPixelBlue(image,ScaleCharToQuantum(*p++),q);
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
break;
}
default:
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
if (image->storage_class == PseudoClass)
(void) SyncImage(image,exception);
tim_pixels=(unsigned char *) RelinquishMagickMemory(tim_pixels);
if (EOFBlob(image) != MagickFalse)
{
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
break;
}
/*
Proceed to next image.
*/
tim_info.id=ReadBlobLSBLong(image);
if (tim_info.id == 0x00000010)
{
/*
Allocate next image structure.
*/
AcquireNextImage(image_info,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
image=SyncNextImageInList(image);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
break;
}
} while (tim_info.id == 0x00000010);
示例5: ReadVIFFImage
//.........这里部分代码省略.........
break;
}
}
}
else if (image->storage_class == PseudoClass)
for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelIndex(image,*p++,q);
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
else
{
/*
Convert DirectColor scanline.
*/
number_pixels=(MagickSizeType) image->columns*image->rows;
for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(image,ScaleCharToQuantum(*p),q);
SetPixelGreen(image,ScaleCharToQuantum(*(p+number_pixels)),q);
SetPixelBlue(image,ScaleCharToQuantum(*(p+2*number_pixels)),q);
if (image->colors != 0)
{
SetPixelRed(image,image->colormap[(ssize_t)
GetPixelRed(image,q)].red,q);
SetPixelGreen(image,image->colormap[(ssize_t)
GetPixelGreen(image,q)].green,q);
SetPixelBlue(image,image->colormap[(ssize_t)
GetPixelBlue(image,q)].blue,q);
}
SetPixelAlpha(image,image->alpha_trait == BlendPixelTrait ?
ScaleCharToQuantum(*(p+number_pixels*3)) : OpaqueAlpha,q);
p++;
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
}
viff_pixels=(unsigned char *) RelinquishMagickMemory(viff_pixels);
if (image->storage_class == PseudoClass)
(void) SyncImage(image,exception);
if (EOFBlob(image) != MagickFalse)
{
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
break;
}
/*
Proceed to next image.
*/
if (image_info->number_scenes != 0)
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
count=ReadBlob(image,1,&viff_info.identifier);
if ((count != 0) && (viff_info.identifier == 0xab))
{
/*
Allocate next image structure.
*/
AcquireNextImage(image_info,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
image=SyncNextImageInList(image);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
break;
}
} while ((count != 0) && (viff_info.identifier == 0xab));
示例6: assert
//.........这里部分代码省略.........
object[i].color.green=object[i].color.green/object[i].area;
object[i].color.blue=object[i].color.blue/object[i].area;
object[i].color.alpha=object[i].color.alpha/object[i].area;
object[i].color.black=object[i].color.black/object[i].area;
object[i].centroid.x=object[i].centroid.x/object[i].area;
object[i].centroid.y=object[i].centroid.y/object[i].area;
}
artifact=GetImageArtifact(image,"connected-components:area-threshold");
area_threshold=0.0;
if (artifact != (const char *) NULL)
area_threshold=StringToDouble(artifact,(char **) NULL);
if (area_threshold > 0.0)
{
/*
Merge object below area threshold.
*/
component_view=AcquireAuthenticCacheView(component_image,exception);
for (i=0; i < (ssize_t) component_image->colors; i++)
{
double
census;
RectangleInfo
bounding_box;
register ssize_t
j;
size_t
id;
if (status == MagickFalse)
continue;
if ((double) object[i].area >= area_threshold)
continue;
for (j=0; j < (ssize_t) component_image->colors; j++)
object[j].census=0;
bounding_box=object[i].bounding_box;
for (y=0; y < (ssize_t) bounding_box.height+2; y++)
{
register const Quantum
*magick_restrict p;
register ssize_t
x;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(component_view,bounding_box.x-1,
bounding_box.y+y-1,bounding_box.width+2,1,exception);
if (p == (const Quantum *) NULL)
{
status=MagickFalse;
continue;
}
for (x=0; x < (ssize_t) bounding_box.width+2; x++)
{
j=(ssize_t) GetPixelIndex(component_image,p);
if (j != i)
object[j].census++;
}
}
census=0;
id=0;
for (j=0; j < (ssize_t) component_image->colors; j++)
if (census < object[j].census)
{
census=object[j].census;
id=(size_t) j;
}
object[id].area+=object[i].area;
for (y=0; y < (ssize_t) bounding_box.height; y++)
{
register Quantum
*magick_restrict q;
register ssize_t
x;
if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(component_view,bounding_box.x,
bounding_box.y+y,bounding_box.width,1,exception);
if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
}
for (x=0; x < (ssize_t) bounding_box.width; x++)
{
if ((ssize_t) GetPixelIndex(component_image,q) == i)
SetPixelIndex(image,(Quantum) id,q);
q+=GetPixelChannels(component_image);
}
if (SyncCacheViewAuthenticPixels(component_view,exception) == MagickFalse)
status=MagickFalse;
}
}
(void) SyncImage(component_image,exception);
}
示例7: ReadRGFImage
//.........这里部分代码省略.........
y;
unsigned char
byte,
*data;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Read RGF header.
*/
image->columns = (unsigned long) ReadBlobByte(image);
image->rows = (unsigned long) ReadBlobByte(image);
image->depth=8;
image->storage_class=PseudoClass;
image->colors=2;
/*
Initialize image structure.
*/
if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
/*
Initialize colormap.
*/
image->colormap[0].red=QuantumRange;
image->colormap[0].green=QuantumRange;
image->colormap[0].blue=QuantumRange;
image->colormap[1].red=(Quantum) 0;
image->colormap[1].green=(Quantum) 0;
image->colormap[1].blue=(Quantum) 0;
if (image_info->ping != MagickFalse)
{
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
/*
Read hex image data.
*/
data=(unsigned char *) AcquireQuantumMemory(image->rows,image->columns*
sizeof(*data));
if (data == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
p=data;
for (i=0; i < (ssize_t) (image->columns * image->rows); i++)
{
*p++=ReadBlobByte(image);
}
/*
Convert RGF image to pixel packets.
*/
p=data;
for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
bit=0;
byte=0;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (bit == 0)
byte=(size_t) (*p++);
SetPixelIndex(image,(Quantum) ((byte & 0x01) != 0 ? 0x01 : 0x00),q);
bit++;
byte>>=1;
if (bit == 8)
bit=0;
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
data=(unsigned char *) RelinquishMagickMemory(data);
(void) SyncImage(image,exception);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
示例8: ReadPCXImage
//.........这里部分代码省略.........
p++;
}
if ((image->columns % 4) != 0)
{
for (i=3; i >= (ssize_t) (4-(image->columns % 4)); i--)
*r++=(unsigned char) ((*p >> (i*2)) & 0x03);
p++;
}
break;
}
case 4:
{
for (x=0; x < ((ssize_t) image->columns-1); x+=2)
{
*r++=(*p >> 4) & 0xf;
*r++=(*p) & 0xf;
p++;
}
if ((image->columns % 2) != 0)
*r++=(*p++ >> 4) & 0xf;
break;
}
case 8:
{
(void) CopyMagickMemory(r,p,image->columns);
break;
}
default:
break;
}
/*
Transfer image scanline.
*/
r=scanline;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (image->storage_class == PseudoClass)
SetPixelIndex(image,*r++,q);
else
{
SetPixelRed(image,ScaleCharToQuantum(*r++),q);
SetPixelGreen(image,ScaleCharToQuantum(*r++),q);
SetPixelBlue(image,ScaleCharToQuantum(*r++),q);
if (image->alpha_trait != UndefinedPixelTrait)
SetPixelAlpha(image,ScaleCharToQuantum(*r++),q);
}
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
if (image->storage_class == PseudoClass)
(void) SyncImage(image,exception);
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
pixel_info=RelinquishVirtualMemory(pixel_info);
if (EOFBlob(image) != MagickFalse)
{
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
break;
}
/*
Proceed to next image.
*/
if (image_info->number_scenes != 0)
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
if (page_table == (MagickOffsetType *) NULL)
break;
if (page_table[id] == 0)
break;
offset=SeekBlob(image,(MagickOffsetType) page_table[id],SEEK_SET);
if (offset < 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
count=ReadBlob(image,1,&pcx_info.identifier);
if ((count != 0) && (pcx_info.identifier == 0x0a))
{
/*
Allocate next image structure.
*/
AcquireNextImage(image_info,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
image=SyncNextImageInList(image);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
break;
}
}
示例9: ModulateImage
//.........这里部分代码省略.........
%
% The format of the ModulateImage method is:
%
% void ModulateImage(Image *image,const char *modulate)
%
% A description of each parameter follows:
%
% o image: The address of a structure of type Image; returned from
% ReadImage.
%
% o modulate: A character string indicating the percent change in brightness,
% saturation, and hue in floating point notation separated by commas
% (e.g. 10.1,0.0,3.1).
%
%
*/
Export void ModulateImage(Image *image,const char *modulate)
{
#define ModulateImageText " Modulating image... "
double
percent_brightness,
percent_hue,
percent_saturation;
int
y;
register int
i,
x;
register PixelPacket
*q;
/*
Initialize gamma table.
*/
assert(image != (Image *) NULL);
if (modulate == (char *) NULL)
return;
percent_hue=0.0;
percent_brightness=0.0;
percent_saturation=0.0;
(void) sscanf(modulate,"%lf,%lf,%lf",&percent_brightness,&percent_saturation,
&percent_hue);
(void) sscanf(modulate,"%lf/%lf/%lf",&percent_brightness,&percent_saturation,
&percent_hue);
switch (image->class)
{
case DirectClass:
default:
{
/*
Modulate the color for a DirectClass image.
*/
for (y=0; y < (int) image->rows; y++)
{
q=GetPixelCache(image,0,y,image->columns,1);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (int) image->columns; x++)
{
Modulate(percent_hue,percent_saturation,percent_brightness,
&q->red,&q->green,&q->blue);
q++;
}
if (!SyncPixelCache(image))
break;
if (QuantumTick(y,image->rows))
ProgressMonitor(ModulateImageText,y,image->rows);
}
break;
}
case PseudoClass:
{
Quantum
blue,
green,
red;
/*
Modulate the color for a PseudoClass image.
*/
for (i=0; i < (int) image->colors; i++)
{
red=image->colormap[i].red;
green=image->colormap[i].green;
blue=image->colormap[i].blue;
Modulate(percent_hue,percent_saturation,percent_brightness,
&red,&green,&blue);
image->colormap[i].red=red;
image->colormap[i].green=green;
image->colormap[i].blue=blue;
}
SyncImage(image);
break;
}
}
}
示例10: GammaImage
//.........这里部分代码省略.........
assert(image != (Image *) NULL);
if (gamma == (char *) NULL)
return;
red_gamma=1.0;
green_gamma=1.0;
blue_gamma=1.0;
opacity_gamma=1.0;
count=sscanf(gamma,"%lf,%lf,%lf,%lf",&red_gamma,&green_gamma,&blue_gamma,
&opacity_gamma);
count=sscanf(gamma,"%lf/%lf/%lf/%lf",&red_gamma,&green_gamma,&blue_gamma,
&opacity_gamma);
if (count == 1)
{
if (red_gamma == 1.0)
return;
green_gamma=red_gamma;
blue_gamma=red_gamma;
}
/*
Allocate and initialize gamma maps.
*/
gamma_map=(PixelPacket *) AllocateMemory((MaxRGB+1)*sizeof(PixelPacket));
if (gamma_map == (PixelPacket *) NULL)
{
MagickWarning(ResourceLimitWarning,"Unable to gamma correct image",
"Memory allocation failed");
return;
}
for (i=0; i <= MaxRGB; i++)
{
gamma_map[i].red=0;
gamma_map[i].green=0;
gamma_map[i].blue=0;
gamma_map[i].opacity=0;
}
/*
Initialize gamma table.
*/
for (i=0; i <= MaxRGB; i++)
{
if (red_gamma != 0.0)
gamma_map[i].red=(Quantum)
((pow((double) i/MaxRGB,1.0/red_gamma)*MaxRGB)+0.5);
if (green_gamma != 0.0)
gamma_map[i].green=(Quantum)
((pow((double) i/MaxRGB,1.0/green_gamma)*MaxRGB)+0.5);
if (blue_gamma != 0.0)
gamma_map[i].blue=(Quantum)
((pow((double) i/MaxRGB,1.0/blue_gamma)*MaxRGB)+0.5);
if (opacity_gamma != 0.0)
gamma_map[i].opacity=(Quantum)
((pow((double) i/MaxRGB,1.0/opacity_gamma)*MaxRGB)+0.5);
}
switch (image->class)
{
case DirectClass:
default:
{
/*
Gamma-correct DirectClass image.
*/
for (y=0; y < (int) image->rows; y++)
{
q=GetPixelCache(image,0,y,image->columns,1);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (int) image->columns; x++)
{
q->red=gamma_map[q->red].red;
q->green=gamma_map[q->green].green;
q->blue=gamma_map[q->blue].blue;
q->opacity=gamma_map[q->opacity].opacity;
q++;
}
if (!SyncPixelCache(image))
break;
if (QuantumTick(y,image->rows))
ProgressMonitor(GammaImageText,y,image->rows);
}
break;
}
case PseudoClass:
{
/*
Gamma-correct PseudoClass image.
*/
for (i=0; i < (int) image->colors; i++)
{
image->colormap[i].red=gamma_map[image->colormap[i].red].red;
image->colormap[i].green=gamma_map[image->colormap[i].green].green;
image->colormap[i].blue=gamma_map[image->colormap[i].blue].blue;
}
SyncImage(image);
break;
}
}
if (image->gamma != 0.0)
image->gamma*=(red_gamma+green_gamma+blue_gamma)/3.0;
FreeMemory(gamma_map);
}
示例11: EqualizeImage
//.........这里部分代码省略.........
*/
assert(image != (Image *) NULL);
histogram=(unsigned int *) AllocateMemory((MaxRGB+1)*sizeof(unsigned int));
map=(unsigned int *) AllocateMemory((MaxRGB+1)*sizeof(unsigned int));
equalize_map=(Quantum *) AllocateMemory((MaxRGB+1)*sizeof(Quantum));
if ((histogram == (unsigned int *) NULL) || (map == (unsigned int *) NULL) ||
(equalize_map == (Quantum *) NULL))
{
MagickWarning(ResourceLimitWarning,"Unable to equalize image",
"Memory allocation failed");
return;
}
/*
Form histogram.
*/
for (i=0; i <= MaxRGB; i++)
histogram[i]=0;
for (y=0; y < (int) image->rows; y++)
{
p=GetPixelCache(image,0,y,image->columns,1);
if (p == (PixelPacket *) NULL)
break;
for (x=0; x < (int) image->columns; x++)
{
histogram[Intensity(*p)]++;
p++;
}
}
/*
Integrate the histogram to get the equalization map.
*/
j=0;
for (i=0; i <= MaxRGB; i++)
{
j+=histogram[i];
map[i]=j;
}
FreeMemory(histogram);
if (map[MaxRGB] == 0)
{
FreeMemory(equalize_map);
FreeMemory(map);
return;
}
/*
Equalize.
*/
low=map[0];
high=map[MaxRGB];
for (i=0; i <= MaxRGB; i++)
equalize_map[i]=(Quantum)
((((double) (map[i]-low))*MaxRGB)/Max(high-low,1));
FreeMemory(map);
/*
Stretch the histogram.
*/
switch (image->class)
{
case DirectClass:
default:
{
/*
Equalize DirectClass packets.
*/
for (y=0; y < (int) image->rows; y++)
{
q=GetPixelCache(image,0,y,image->columns,1);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (int) image->columns; x++)
{
q->red=equalize_map[q->red];
q->green=equalize_map[q->green];
q->blue=equalize_map[q->blue];
q++;
}
if (!SyncPixelCache(image))
break;
if (QuantumTick(y,image->rows))
ProgressMonitor(EqualizeImageText,y,image->rows);
}
break;
}
case PseudoClass:
{
/*
Equalize PseudoClass packets.
*/
for (i=0; i < (int) image->colors; i++)
{
image->colormap[i].red=equalize_map[image->colormap[i].red];
image->colormap[i].green=equalize_map[image->colormap[i].green];
image->colormap[i].blue=equalize_map[image->colormap[i].blue];
}
SyncImage(image);
break;
}
}
FreeMemory(equalize_map);
}
示例12: ReadOTBImage
//.........这里部分代码省略.........
register ssize_t
x;
register PixelPacket
*q;
ssize_t
y;
unsigned char
bit,
info,
depth;
/*
Open image file.
*/
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);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Initialize image structure.
*/
info=(unsigned char) ReadBlobByte(image);
if (GetBit(info,4) == 0)
{
image->columns=(size_t) ReadBlobByte(image);
image->rows=(size_t) ReadBlobByte(image);
}
else
{
image->columns=(size_t) ReadBlobMSBShort(image);
image->rows=(size_t) ReadBlobMSBShort(image);
}
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
depth=(unsigned char) ReadBlobByte(image);
if (depth != 1)
ThrowReaderException(CoderError,"OnlyLevelZerofilesSupported");
if (AcquireImageColormap(image,2) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if (image_info->ping != MagickFalse)
{
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
/*
Convert bi-level image to pixel packets.
*/
for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
bit=0;
byte=0;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (bit == 0)
{
byte=ReadBlobByte(image);
if (byte == EOF)
ThrowReaderException(CorruptImageError,"CorruptImage");
}
SetPixelIndex(indexes+x,(byte & (0x01 << (7-bit))) ?
0x00 : 0x01);
bit++;
if (bit == 8)
bit=0;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
(void) SyncImage(image);
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
示例13: assert
//.........这里部分代码省略.........
}
if ((image->columns % 4) != 0)
{
for (i=3; i >= (long) (4-(image->columns % 4)); i--)
*r++=(unsigned char) ((*p >> (i*2)) & 0x03);
p++;
}
break;
}
case 4:
{
for (x=0; x < ((long) image->columns-1); x+=2)
{
*r++=(*p >> 4) & 0xf;
*r++=(*p) & 0xf;
p++;
}
if ((image->columns % 2) != 0)
*r++=(*p++ >> 4) & 0xf;
break;
}
case 8:
{
(void) CopyMagickMemory(r,p,image->columns);
break;
}
default:
break;
}
/*
Transfer image scanline.
*/
r=scanline;
for (x=0; x < (long) image->columns; x++)
{
if (image->storage_class == PseudoClass)
indexes[x]=(IndexPacket) (*r++);
else
{
q->red=ScaleCharToQuantum(*r++);
q->green=ScaleCharToQuantum(*r++);
q->blue=ScaleCharToQuantum(*r++);
if (image->matte != MagickFalse)
q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(*r++));
}
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,y,image->rows);
if (status == MagickFalse)
break;
}
}
if (image->storage_class == PseudoClass)
(void) SyncImage(image);
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
if (pcx_colormap != (unsigned char *) NULL)
pcx_colormap=(unsigned char *) RelinquishMagickMemory(pcx_colormap);
pcx_pixels=(unsigned char *) RelinquishMagickMemory(pcx_pixels);
if (EOFBlob(image) != MagickFalse)
{
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
break;
}
/*
Proceed to next image.
*/
if (image_info->number_scenes != 0)
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
if (page_table == (MagickOffsetType *) NULL)
break;
if (page_table[id] == 0)
break;
offset=SeekBlob(image,(MagickOffsetType) page_table[id],SEEK_SET);
if (offset < 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
count=ReadBlob(image,1,&pcx_info.identifier);
if ((count != 0) && (pcx_info.identifier == 0x0a))
{
/*
Allocate next image structure.
*/
AcquireNextImage(image_info,image);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
image=SyncNextImageInList(image);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
break;
}
}
示例14: ReadSTEGANOImage
//.........这里部分代码省略.........
pixel;
register IndexPacket
*indexes;
register long
x;
register PixelPacket
*q;
/*
Initialize Image structure.
*/
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=AllocateImage(image_info);
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(OptionError,"MustSpecifyImageSize");
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
*read_info->magick='\0';
watermark=ReadImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
if (watermark == (Image *) NULL)
return((Image *) NULL);
watermark->depth=QuantumDepth;
if (AllocateImageColormap(image,MaxColormapSize) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if (image_info->ping != MagickFalse)
{
CloseBlob(image);
return(GetFirstImageInList(image));
}
/*
Get hidden watermark from low-order bits of image.
*/
c=0;
i=0;
j=0;
k=image->offset;
for (i=QuantumDepth-1; (i >= 0) && (j < QuantumDepth); i--)
{
for (y=0; (y < (long) image->rows) && (j < QuantumDepth); y++)
{
for (x=0; (x < (long) image->columns) && (j < QuantumDepth); x++)
{
pixel=AcquireOnePixel(watermark,k % (long) watermark->columns,
k/(long) watermark->columns,exception);
q=GetImagePixels(image,x,y,1,1);
if (q == (PixelPacket *) NULL)
break;
indexes=GetIndexes(image);
switch (c)
{
case 0:
{
SetBit(*indexes,i,GetBit(pixel.red,j));
break;
}
case 1:
{
SetBit(*indexes,i,GetBit(pixel.green,j));
break;
}
case 2:
{
SetBit(*indexes,i,GetBit(pixel.blue,j));
break;
}
}
(void) SyncImage(image);
c++;
if (c == 3)
c=0;
k++;
if (k == (long) (watermark->columns*watermark->columns))
k=0;
if (k == image->offset)
j++;
}
}
if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
(QuantumTick(i,QuantumDepth) != MagickFalse))
{
status=image->progress_monitor(LoadImagesTag,i,QuantumDepth,
image->client_data);
if (status == MagickFalse)
break;
}
}
watermark=DestroyImage(watermark);
SyncImage(image);
return(GetFirstImageInList(image));
}
示例15: get_page_image
//.........这里部分代码省略.........
static void
get_page_image(LoadContext *lc, ddjvu_page_t *page, int x, int y, int w, int h, const ImageInfo *image_info ) {
ddjvu_format_t
*format;
ddjvu_page_type_t
type;
Image
*image;
int
ret,
stride;
unsigned char
*q;
ddjvu_rect_t rect;
rect.x = x;
rect.y = y;
rect.w = (unsigned int) w; /* /10 */
rect.h = (unsigned int) h; /* /10 */
image = lc->image;
type = ddjvu_page_get_type(lc->page);
/* stride of this temporary buffer: */
stride = (type == DDJVU_PAGETYPE_BITONAL)?
(image->columns + 7)/8 : image->columns *3;
q = (unsigned char *) AcquireQuantumMemory(image->rows,stride);
if (q == (unsigned char *) NULL)
return;
format = ddjvu_format_create(
(type == DDJVU_PAGETYPE_BITONAL)?DDJVU_FORMAT_LSBTOMSB : DDJVU_FORMAT_RGB24,
/* DDJVU_FORMAT_RGB24
* DDJVU_FORMAT_RGBMASK32*/
/* DDJVU_FORMAT_RGBMASK32 */
0, NULL);
#if 0
/* fixme: ThrowReaderException is a macro, which uses `exception' variable */
if (format == NULL)
{
abort();
/* ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); */
}
#endif
ddjvu_format_set_row_order(format, 1);
ddjvu_format_set_y_direction(format, 1);
ret = ddjvu_page_render(page,
DDJVU_RENDER_COLOR, /* ddjvu_render_mode_t */
&rect,
&rect, /* mmc: ?? */
format,
stride, /* ?? */
(char*)q);
(void) ret;
ddjvu_format_release(format);
if (type == DDJVU_PAGETYPE_BITONAL) {
/* */
#if DEBUG
printf("%s: expanding BITONAL page/image\n", __FUNCTION__);
#endif
register IndexPacket *indexes;
size_t bit, byte;
for (y=0; y < (ssize_t) image->rows; y++)
{
PixelPacket * o = QueueAuthenticPixels(image,0,y,image->columns,1,&image->exception);
if (o == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
bit=0;
byte=0;
/* fixme: the non-aligned, last =<7 bits ! that's ok!!!*/
for (x= 0; x < (ssize_t) image->columns; x++)
{
if (bit == 0) byte= (size_t) q[(y * stride) + (x / 8)];
if (indexes != (IndexPacket *) NULL)
SetPixelIndex(indexes+x,(IndexPacket) (((byte & 0x01) != 0) ? 0x00 : 0x01));
bit++;
if (bit == 8)
bit=0;
byte>>=1;
}
if (SyncAuthenticPixels(image,&image->exception) == MagickFalse)
break;
}
if (!image->ping)
SyncImage(image);
} else {