您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetPixelIndex函数代码示例

51自学网 2021-06-01 21:12:46
  C++
这篇教程C++ GetPixelIndex函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GetPixelIndex函数的典型用法代码示例。如果您正苦于以下问题:C++ GetPixelIndex函数的具体用法?C++ GetPixelIndex怎么用?C++ GetPixelIndex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GetPixelIndex函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CycleColormap

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                             %%                                                                             %%                                                                             %%     C y c l e C o l o r m a p I m a g e                                     %%                                                                             %%                                                                             %%                                                                             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  CycleColormap() displaces an image's colormap by a given number of%  positions.  If you cycle the colormap a number of times you can produce%  a psychodelic effect.%%  WARNING: this assumes an images colormap is in a well know and defined%  order. Currently Imagemagick has no way of setting that order.%%  The format of the CycleColormapImage method is:%%      MagickBooleanType CycleColormapImage(Image *image,const ssize_t displace,%        ExceptionInfo *exception)%%  A description of each parameter follows:%%    o image: the image.%%    o displace:  displace the colormap this amount.%%    o exception: return any errors or warnings in this structure.%*/MagickExport MagickBooleanType CycleColormapImage(Image *image,  const ssize_t displace,ExceptionInfo *exception){  CacheView    *image_view;  MagickBooleanType    status;  ssize_t    y;  assert(image != (Image *) NULL);  assert(image->signature == MagickCoreSignature);  if (image->debug != MagickFalse)    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);  if (image->storage_class == DirectClass)    (void) SetImageType(image,PaletteType,exception);  status=MagickTrue;  image_view=AcquireAuthenticCacheView(image,exception);#if defined(MAGICKCORE_OPENMP_SUPPORT)  #pragma omp parallel for schedule(static,4) /    magick_threads(image,image,1,1)#endif  for (y=0; y < (ssize_t) image->rows; y++)  {    register ssize_t      x;    register Quantum      *restrict q;    ssize_t      index;    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++)    {      index=(ssize_t) (GetPixelIndex(image,q)+displace) % image->colors;      if (index < 0)        index+=(ssize_t) image->colors;      SetPixelIndex(image,(Quantum) index,q);      SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);      q+=GetPixelChannels(image);    }    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)      status=MagickFalse;  }  image_view=DestroyCacheView(image_view);  return(status);}
开发者ID:jeffasd,项目名称:ImageMagick,代码行数:90,


示例2: GetPixelColor

RGBQUAD CxDib::GetPixelColor(long x,long y){	RGBQUAD rgb={0,0,0,0};	if ((hDib==NULL)||(x<0)||(y<0)||		(x>=m_bi.biWidth)||(y>=m_bi.biHeight)) return rgb;	if (m_nColors) return GetPaletteIndex(GetPixelIndex(x,y));	else {		BYTE* iDst = GetBits()+(m_bi.biHeight - y)*m_LineWidth + x*sizeof(RGBQUAD);		rgb.rgbBlue = *iDst++;		rgb.rgbGreen= *iDst++;		rgb.rgbRed =*iDst;		return rgb;	}}
开发者ID:F5000,项目名称:spree,代码行数:14,


示例3: GetImageTotalInkDensity

/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                             %%                                                                             %%                                                                             %%   G e t I m a g e T o t a l I n k D e n s i t y                             %%                                                                             %%                                                                             %%                                                                             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  GetImageTotalInkDensity() returns the total ink density for a CMYK image.%  Total Ink Density (TID) is determined by adding the CMYK values in the%  darkest shadow area in an image.%%  The format of the GetImageTotalInkDensity method is:%%      double GetImageTotalInkDensity(const Image *image)%%  A description of each parameter follows:%%    o image: the image.%*/MagickExport double GetImageTotalInkDensity(Image *image){  CacheView    *image_view;  double    total_ink_density;  ExceptionInfo    *exception;  MagickBooleanType    status;  ssize_t    y;  assert(image != (Image *) NULL);  if (image->debug != MagickFalse)    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");  assert(image->signature == MagickSignature);  if (image->colorspace != CMYKColorspace)    {      (void) ThrowMagickException(&image->exception,GetMagickModule(),        ImageError,"ColorSeparatedImageRequired","`%s'",image->filename);      return(0.0);    }  status=MagickTrue;  total_ink_density=0.0;  exception=(&image->exception);  image_view=AcquireVirtualCacheView(image,exception);#if defined(MAGICKCORE_OPENMP_SUPPORT)  #pragma omp parallel for schedule(static,4) shared(status) /    dynamic_number_threads(image,image->columns,image->rows,1)#endif  for (y=0; y < (ssize_t) image->rows; y++)  {    double      density;    register const IndexPacket      *indexes;    register const PixelPacket      *p;    register ssize_t      x;    p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);    if (p == (const PixelPacket *) NULL)      {        status=MagickFalse;        continue;      }    indexes=GetCacheViewVirtualIndexQueue(image_view);    for (x=0; x < (ssize_t) image->columns; x++)    {      density=(double) GetPixelRed(p)+GetPixelGreen(p)+        GetPixelBlue(p)+GetPixelIndex(indexes+x);      if (density > total_ink_density)#if defined(MAGICKCORE_OPENMP_SUPPORT)        #pragma omp critical (MagickCore_GetImageTotalInkDensity)#endif        {          if (density > total_ink_density)            total_ink_density=density;        }      p++;    }  }  image_view=DestroyCacheView(image_view);  if (status == MagickFalse)    total_ink_density=0.0;  return(total_ink_density);}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:100,


示例4: WriteSIXELImage

//.........这里部分代码省略.........  /*    Open output image file.  */  assert(image_info != (const ImageInfo *) NULL);  assert(image_info->signature == MagickSignature);  assert(image != (Image *) NULL);  assert(image->signature == MagickSignature);  if (image->debug != MagickFalse)    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);  exception=(&image->exception);  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);  if (status == MagickFalse)    return(status);  if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)    (void) TransformImageColorspace(image,sRGBColorspace);  opacity=(-1);  if (image->matte == MagickFalse)    {      if ((image->storage_class == DirectClass) || (image->colors > 256))        (void) SetImageType(image,PaletteType);    }  else    {      MagickRealType        alpha,        beta;      /*        Identify transparent colormap index.      */      if ((image->storage_class == DirectClass) || (image->colors > 256))        (void) SetImageType(image,PaletteBilevelMatteType);      for (i=0; i < (ssize_t) image->colors; i++)        if (image->colormap[i].opacity != OpaqueOpacity)          {            if (opacity < 0)              {                opacity=i;                continue;              }            alpha=(MagickRealType) image->colormap[i].opacity;            beta=(MagickRealType) image->colormap[opacity].opacity;            if (alpha > beta)              opacity=i;          }      if (opacity == -1)        {          (void) SetImageType(image,PaletteBilevelMatteType);          for (i=0; i < (ssize_t) image->colors; i++)            if (image->colormap[i].opacity != OpaqueOpacity)              {                if (opacity < 0)                  {                    opacity=i;                    continue;                  }                alpha=(MagickRealType) image->colormap[i].opacity;                beta=(MagickRealType) image->colormap[opacity].opacity;                if (alpha > beta)                  opacity=i;              }        }      if (opacity >= 0)        {          image->colormap[opacity].red=image->transparent_color.red;          image->colormap[opacity].green=image->transparent_color.green;          image->colormap[opacity].blue=image->transparent_color.blue;        }    }  /*    SIXEL header.  */  for (i=0; i < (ssize_t) image->colors; i++)  {    sixel_palette[i * 3 + 0] = ScaleQuantumToChar(image->colormap[i].red);    sixel_palette[i * 3 + 1] = ScaleQuantumToChar(image->colormap[i].green);    sixel_palette[i * 3 + 2] = ScaleQuantumToChar(image->colormap[i].blue);  }  /*    Define SIXEL pixels.  */  output = sixel_output_create(image);  sixel_pixels =(unsigned char *) AcquireQuantumMemory(image->columns * image->rows,1);  for (y=0; y < (ssize_t) image->rows; y++)  {    (void) GetVirtualPixels(image,0,y,image->columns,1,exception);    indexes=GetVirtualIndexQueue(image);    for (x=0; x < (ssize_t) image->columns; x++)      sixel_pixels[y * image->columns + x] = (unsigned char) ((ssize_t) GetPixelIndex(indexes + x));  }  status = sixel_encode_impl(sixel_pixels, image->columns, image->rows,                          sixel_palette, image->colors, -1,                          output);  sixel_pixels =(unsigned char *) RelinquishMagickMemory(sixel_pixels);  output = (sixel_output_t *) RelinquishMagickMemory(output);  (void) CloseBlob(image);  return(status);}
开发者ID:CamiloBenavides,项目名称:SnoutPoint-Web,代码行数:101,


示例5: GetPalette

//.........这里部分代码省略.........    }    TIFFSetField(m_tif, TIFFTAG_COMPRESSION, compression);    switch (compression) {    case COMPRESSION_JPEG:        TIFFSetField(m_tif, TIFFTAG_JPEGQUALITY, info.nQuality);        TIFFSetField(m_tif, TIFFTAG_ROWSPERSTRIP, ((7+rowsperstrip)>>3)<<3);        break;    case COMPRESSION_LZW:        if (bitcount>=8) TIFFSetField(m_tif, TIFFTAG_PREDICTOR, 2);        break;    }    // read the DIB lines from bottom to top and save them in the TIF    BYTE *bits;    switch(bitcount) {				        case 1 :        case 4 :        case 8 :        {            if (samplesperpixel==1){                for (y = 0; y < height; y++) {                    bits= info.pImage + (height - y - 1)*info.dwEffWidth;                    if (TIFFWriteScanline(m_tif,bits, y, 0)==-1) return false;                }            }#if CXIMAGE_SUPPORT_ALPHA            else { //8bpp + alpha layer                bits = (BYTE*)malloc(2*width);                if (!bits) return false;                for (y = 0; y < height; y++) {                    for (x=0;x<width;x++){                        bits[2*x]=GetPixelIndex(x,height - y - 1);                        bits[2*x+1]=AlphaGet(x,height - y - 1);                    }                    if (TIFFWriteScanline(m_tif,bits, y, 0)==-1) {                        free(bits);                        return false;                    }                }                free(bits);            }#endif //CXIMAGE_SUPPORT_ALPHA            break;        }				        case 24:        {            BYTE *buffer = (BYTE *)malloc(info.dwEffWidth);            if (!buffer) return false;            for (y = 0; y < height; y++) {                // get a pointer to the scanline                memcpy(buffer, info.pImage + (height - y - 1)*info.dwEffWidth, info.dwEffWidth);                // TIFFs store color data RGB instead of BGR                BYTE *pBuf = buffer;                for (x = 0; x < width; x++) {                    BYTE tmp = pBuf[0];                    pBuf[0] = pBuf[2];                    pBuf[2] = tmp;                    pBuf += 3;                }                // write the scanline to disc                if (TIFFWriteScanline(m_tif, buffer, y, 0)==-1){                    free(buffer);                    return false;                }
开发者ID:dehilsterlexis,项目名称:eclide-1,代码行数:67,


示例6: WriteXPMImage

//.........这里部分代码省略.........          image->colormap[opacity].green=image->transparent_color.green;          image->colormap[opacity].blue=image->transparent_color.blue;        }    }  /*    Compute the character per pixel.  */  characters_per_pixel=1;  for (k=MaxCixels; (ssize_t) image->colors > k; k*=MaxCixels)    characters_per_pixel++;  /*    XPM header.  */  (void) WriteBlobString(image,"/* XPM *//n");  GetPathComponent(image->filename,BasePath,basename);  if (isalnum((int) ((unsigned char) *basename)) == 0)    {      (void) FormatLocaleString(buffer,MaxTextExtent,"xpm_%s",basename);      (void) CopyMagickString(basename,buffer,MaxTextExtent);    }  if (isalpha((int) ((unsigned char) basename[0])) == 0)    basename[0]='_';  for (i=1; basename[i] != '/0'; i++)    if (isalnum((int) ((unsigned char) basename[i])) == 0)      basename[i]='_';  (void) FormatLocaleString(buffer,MaxTextExtent,    "static char *%s[] = {/n",basename);  (void) WriteBlobString(image,buffer);  (void) WriteBlobString(image,"/* columns rows colors chars-per-pixel *//n");  (void) FormatLocaleString(buffer,MaxTextExtent,    "/"%.20g %.20g %.20g %.20g /",/n",(double) image->columns,(double)    image->rows,(double) image->colors,(double) characters_per_pixel);  (void) WriteBlobString(image,buffer);  GetMagickPixelPacket(image,&pixel);  for (i=0; i < (ssize_t) image->colors; i++)  {    /*      Define XPM color.    */    SetMagickPixelPacket(image,image->colormap+i,(IndexPacket *) NULL,&pixel);    pixel.colorspace=sRGBColorspace;    pixel.depth=8;    pixel.opacity=(MagickRealType) OpaqueOpacity;    (void) QueryMagickColorname(image,&pixel,XPMCompliance,name,exception);    if (i == opacity)      (void) CopyMagickString(name,"None",MaxTextExtent);    /*      Write XPM color.    */    k=i % MaxCixels;    symbol[0]=Cixel[k];    for (j=1; j < (ssize_t) characters_per_pixel; j++)    {      k=((i-k)/MaxCixels) % MaxCixels;      symbol[j]=Cixel[k];    }    symbol[j]='/0';    (void) FormatLocaleString(buffer,MaxTextExtent,"/"%s c %s/",/n",symbol,      name);    (void) WriteBlobString(image,buffer);  }  /*    Define XPM pixels.  */  (void) WriteBlobString(image,"/* pixels *//n");  for (y=0; y < (ssize_t) image->rows; y++)  {    p=GetVirtualPixels(image,0,y,image->columns,1,exception);    if (p == (const PixelPacket *) NULL)      break;    indexes=GetVirtualIndexQueue(image);    (void) WriteBlobString(image,"/"");    for (x=0; x < (ssize_t) image->columns; x++)    {      k=((ssize_t) GetPixelIndex(indexes+x) % MaxCixels);      symbol[0]=Cixel[k];      for (j=1; j < (ssize_t) characters_per_pixel; j++)      {        k=(((int) GetPixelIndex(indexes+x)-k)/MaxCixels) % MaxCixels;        symbol[j]=Cixel[k];      }      symbol[j]='/0';      (void) CopyMagickString(buffer,symbol,MaxTextExtent);      (void) WriteBlobString(image,buffer);    }    (void) FormatLocaleString(buffer,MaxTextExtent,"/"%s/n",      (y == (ssize_t) (image->rows-1) ? "" : ","));    (void) WriteBlobString(image,buffer);    if (image->previous == (Image *) NULL)      {        status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,          image->rows);        if (status == MagickFalse)          break;      }  }  (void) WriteBlobString(image,"};/n");  (void) CloseBlob(image);  return(MagickTrue);}
开发者ID:MarinaAndenko,项目名称:MyBlog,代码行数:101,


示例7: ReadVIFFImage

//.........这里部分代码省略.........            if (viff_info.map_scheme == VFF_MS_NONE)            {                value=(value-min_value)*scale_factor;                if (value > QuantumRange)                    value=QuantumRange;                else if (value < 0)                    value=0;            }            *p=(unsigned char) value;            p++;        }        /*          Convert VIFF raster image to pixel packets.        */        p=(unsigned char *) viff_pixels;        if (viff_info.data_storage_type == VFF_TYP_BIT)        {            /*              Convert bitmap scanline.            */            (void) SetImageType(image,BilevelType,exception);            (void) SetImageType(image,PaletteType,exception);            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-7); x+=8)                {                    for (bit=0; bit < 8; bit++)                    {                        if (GetPixelLuma(image,q) < (QuantumRange/2.0))                        {                            quantum=(size_t) GetPixelIndex(image,q);                            quantum|=0x01;                            SetPixelIndex(image,quantum,q);                        }                        q+=GetPixelChannels(image);                    }                    p++;                }                if ((image->columns % 8) != 0)                {                    for (bit=0; bit < (ssize_t) (image->columns % 8); bit++)                        if (GetPixelLuma(image,q) < (QuantumRange/2.0))                        {                            quantum=(size_t) GetPixelIndex(image,q);                            quantum|=0x01;                            SetPixelIndex(image,quantum,q);                            q+=GetPixelChannels(image);                        }                    p++;                }                if (SyncAuthenticPixels(image,exception) == MagickFalse)                    break;                if (image->previous == (Image *) NULL)                {                    status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,                                            image->rows);                    if (status == MagickFalse)                        break;                }            }        }        else if (image->storage_class == PseudoClass)            for (y=0; y < (ssize_t) image->rows; y++)
开发者ID:verma-manish58,项目名称:ImageMagick,代码行数:67,


示例8: WriteUILImage

//.........这里部分代码省略.........                }            }        }        if (matte_image != (unsigned char *) NULL)            matte_image=(unsigned char *) RelinquishMagickMemory(matte_image);    }    /*      Compute the character per pixel.    */    characters_per_pixel=1;    for (k=MaxCixels; (ssize_t) colors > k; k*=MaxCixels)        characters_per_pixel++;    /*      UIL header.    */    symbol=AcquireString("");    (void) WriteBlobString(image,"/* UIL *//n");    GetPathComponent(image->filename,BasePath,basename);    (void) FormatLocaleString(buffer,MagickPathExtent,                              "value/n  %s_ct : color_table(/n",basename);    (void) WriteBlobString(image,buffer);    GetPixelInfo(image,&pixel);    for (i=0; i < (ssize_t) colors; i++)    {        /*          Define UIL color.        */        pixel=image->colormap[i];        pixel.colorspace=sRGBColorspace;        pixel.depth=8;        pixel.alpha=(double) OpaqueAlpha;        GetColorTuple(&pixel,MagickTrue,name);        if (transparent != MagickFalse)            if (i == (ssize_t) (colors-1))                (void) CopyMagickString(name,"None",MagickPathExtent);        /*          Write UIL color.        */        k=i % MaxCixels;        symbol[0]=Cixel[k];        for (j=1; j < (int) characters_per_pixel; j++)        {            k=((i-k)/MaxCixels) % MaxCixels;            symbol[j]=Cixel[k];        }        symbol[j]='/0';        (void) SubstituteString(&symbol,"'","''");        if (LocaleCompare(name,"None") == 0)            (void) FormatLocaleString(buffer,MagickPathExtent,                                      "    background color = '%s'",symbol);        else            (void) FormatLocaleString(buffer,MagickPathExtent,                                      "    color('%s',%s) = '%s'",name,                                      GetPixelInfoIntensity(image,image->colormap+i) <                                      (QuantumRange/2.0) ? "background" : "foreground",symbol);        (void) WriteBlobString(image,buffer);        (void) FormatLocaleString(buffer,MagickPathExtent,"%s",                                  (i == (ssize_t) (colors-1) ? ");/n" : ",/n"));        (void) WriteBlobString(image,buffer);    }    /*      Define UIL pixels.    */    GetPathComponent(image->filename,BasePath,basename);    (void) FormatLocaleString(buffer,MagickPathExtent,                              "  %s_icon : icon(color_table = %s_ct,/n",basename,basename);    (void) WriteBlobString(image,buffer);    for (y=0; y < (ssize_t) image->rows; y++)    {        p=GetVirtualPixels(image,0,y,image->columns,1,exception);        if (p == (const Quantum *) NULL)            break;        (void) WriteBlobString(image,"    /"");        for (x=0; x < (ssize_t) image->columns; x++)        {            k=((ssize_t) GetPixelIndex(image,p) % MaxCixels);            symbol[0]=Cixel[k];            for (j=1; j < (int) characters_per_pixel; j++)            {                k=(((int) GetPixelIndex(image,p)-k)/MaxCixels) %                  MaxCixels;                symbol[j]=Cixel[k];            }            symbol[j]='/0';            (void) CopyMagickString(buffer,symbol,MagickPathExtent);            (void) WriteBlobString(image,buffer);            p+=GetPixelChannels(image);        }        (void) FormatLocaleString(buffer,MagickPathExtent,"/"%s/n",                                  (y == (ssize_t) (image->rows-1) ? ");" : ","));        (void) WriteBlobString(image,buffer);        status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,                                image->rows);        if (status == MagickFalse)            break;    }    symbol=DestroyString(symbol);    (void) CloseBlob(image);    return(MagickTrue);}
开发者ID:JosephineWolff,项目名称:ImageMagick,代码行数:101,


示例9: ForwardFourierTransform

static MagickBooleanType ForwardFourierTransform(FourierInfo *fourier_info,  const Image *image,double *magnitude,double *phase,ExceptionInfo *exception){  CacheView    *image_view;  double    n,    *source;  fftw_complex    *fourier;  fftw_plan    fftw_r2c_plan;  register const IndexPacket    *indexes;  register const PixelPacket    *p;  register ssize_t    i,    x;  ssize_t    y;  /*    Generate the forward Fourier transform.  */  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);    }  ResetMagickMemory(source,0,fourier_info->height*fourier_info->width*    sizeof(*source));  i=0L;  image_view=AcquireVirtualCacheView(image,exception);  for (y=0L; y < (ssize_t) fourier_info->height; y++)  {    p=GetCacheViewVirtualPixels(image_view,0L,y,fourier_info->width,1UL,      exception);    if (p == (const PixelPacket *) NULL)      break;    indexes=GetCacheViewVirtualIndexQueue(image_view);    for (x=0L; x < (ssize_t) fourier_info->width; x++)    {      switch (fourier_info->channel)      {        case RedChannel:        default:        {          source[i]=QuantumScale*GetPixelRed(p);          break;        }        case GreenChannel:        {          source[i]=QuantumScale*GetPixelGreen(p);          break;        }        case BlueChannel:        {          source[i]=QuantumScale*GetPixelBlue(p);          break;        }        case OpacityChannel:        {          source[i]=QuantumScale*GetPixelOpacity(p);          break;        }        case IndexChannel:        {          source[i]=QuantumScale*GetPixelIndex(indexes+x);          break;        }        case GrayChannels:        {          source[i]=QuantumScale*GetPixelGray(p);          break;        }      }      i++;      p++;    }  }  image_view=DestroyCacheView(image_view);  fourier=(fftw_complex *) AcquireQuantumMemory((size_t) fourier_info->height,    fourier_info->center*sizeof(*fourier));  if (fourier == (fftw_complex *) NULL)    {      (void) ThrowMagickException(exception,GetMagickModule(),        ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);      source=(double *) RelinquishMagickMemory(source);      return(MagickFalse);//.........这里部分代码省略.........
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:101,


示例10: WriteVIPSImage

//.........这里部分代码省略.........  else    (void) WriteBlobLSBLong(image,VIPS_MAGIC_MSB);  (void) WriteBlobLong(image,(unsigned int) image->columns);  (void) WriteBlobLong(image,(unsigned int) image->rows);  (void) SetImageStorageClass(image,DirectClass);  channels=image->matte ? 4 : 3;  if (SetImageGray(image,&image->exception) != MagickFalse)    channels=image->matte ? 2 : 1;  else if (image->colorspace == CMYKColorspace)    channels=image->matte ? 5 : 4;  (void) WriteBlobLong(image,channels);  (void) WriteBlobLong(image,0);  if (image->depth == 16)    (void) WriteBlobLong(image,(unsigned int) VIPSBandFormatUSHORT);  else    {      image->depth=8;      (void) WriteBlobLong(image,(unsigned int) VIPSBandFormatUCHAR);    }  (void) WriteBlobLong(image,VIPSCodingNONE);  switch(image->colorspace)  {    case CMYKColorspace:      (void) WriteBlobLong(image,VIPSTypeCMYK);      break;    case GRAYColorspace:      if (image->depth == 16)        (void) WriteBlobLong(image, VIPSTypeGREY16);      else        (void) WriteBlobLong(image, VIPSTypeB_W);      break;    case RGBColorspace:      if (image->depth == 16)        (void) WriteBlobLong(image, VIPSTypeRGB16);      else        (void) WriteBlobLong(image, VIPSTypeRGB);      break;    default:    case sRGBColorspace:      (void) SetImageColorspace(image,sRGBColorspace);      (void) WriteBlobLong(image,VIPSTypesRGB);      break;  }  if (image->units == PixelsPerCentimeterResolution)    {      (void) WriteBlobFloat(image,(image->x_resolution / 10));      (void) WriteBlobFloat(image,(image->y_resolution / 10));    }  else if (image->units == PixelsPerInchResolution)    {      (void) WriteBlobFloat(image,(image->x_resolution / 25.4));      (void) WriteBlobFloat(image,(image->y_resolution / 25.4));    }  else    {      (void) WriteBlobLong(image,0);      (void) WriteBlobLong(image,0);    }  /*    Legacy, Offsets, Future  */  for (y=0; y < 24; y++)    (void) WriteBlobByte(image,0);  for (y=0; y < (ssize_t) image->rows; y++)  {    p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);    if (p == (const PixelPacket *) NULL)      break;    indexes=GetVirtualIndexQueue(image);    for (x=0; x < (ssize_t) image->columns; x++)    {      WriteVIPSPixel(image,GetPixelRed(p));      if (channels == 2)        WriteVIPSPixel(image,GetPixelAlpha(p));      else        {          WriteVIPSPixel(image,GetPixelGreen(p));          WriteVIPSPixel(image,GetPixelBlue(p));          if (channels >= 4)            {              if (image->colorspace == CMYKColorspace)                WriteVIPSPixel(image,GetPixelIndex(indexes+x));              else                WriteVIPSPixel(image,GetPixelAlpha(p));            }          else if (channels == 5)            {               WriteVIPSPixel(image,GetPixelIndex(indexes+x));               WriteVIPSPixel(image,GetPixelAlpha(p));            }        }      p++;    }  }  metadata=GetImageProperty(image,"vips:metadata");  if (metadata != (const char*) NULL)    WriteBlobString(image,metadata);  (void) CloseBlob(image);  return(status);}
开发者ID:JohnHeywardOBrien,项目名称:photogram,代码行数:101,


示例11: assert

//.........这里部分代码省略.........  image_view=AcquireCacheView(image);#if defined(MAGICKCORE_OPENMP_SUPPORT)  #pragma omp parallel for schedule(static,4) shared(status)#endif  for (y=0; y < (ssize_t) image->rows; y++)  {    register const IndexPacket      *restrict indexes;    register const PixelPacket      *restrict p;    register ssize_t      x;    if (status == MagickFalse)      continue;    p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);    if (p == (const PixelPacket *) NULL)      {        status=MagickFalse;        continue;      }    indexes=GetCacheViewVirtualIndexQueue(image_view);    for (x=0; x < (ssize_t) image->columns; x++)    {      grays[ScaleQuantumToMap(GetPixelRed(p))].red=        ScaleQuantumToMap(GetPixelRed(p));      grays[ScaleQuantumToMap(GetPixelGreen(p))].green=        ScaleQuantumToMap(GetPixelGreen(p));      grays[ScaleQuantumToMap(GetPixelBlue(p))].blue=        ScaleQuantumToMap(GetPixelBlue(p));      if (image->colorspace == CMYKColorspace)        grays[ScaleQuantumToMap(GetPixelIndex(indexes+x))].index=          ScaleQuantumToMap(GetPixelIndex(indexes+x));      if (image->matte != MagickFalse)        grays[ScaleQuantumToMap(GetPixelOpacity(p))].opacity=          ScaleQuantumToMap(GetPixelOpacity(p));      p++;    }  }  image_view=DestroyCacheView(image_view);  if (status == MagickFalse)    {      grays=(LongPixelPacket *) RelinquishMagickMemory(grays);      channel_features=(ChannelFeatures *) RelinquishMagickMemory(        channel_features);      return(channel_features);    }  (void) ResetMagickMemory(&gray,0,sizeof(gray));  for (i=0; i <= (ssize_t) MaxMap; i++)  {    if (grays[i].red != ~0U)      grays[(ssize_t) gray.red++].red=grays[i].red;    if (grays[i].green != ~0U)      grays[(ssize_t) gray.green++].green=grays[i].green;    if (grays[i].blue != ~0U)      grays[(ssize_t) gray.blue++].blue=grays[i].blue;    if (image->colorspace == CMYKColorspace)      if (grays[i].index != ~0U)        grays[(ssize_t) gray.index++].index=grays[i].index;    if (image->matte != MagickFalse)      if (grays[i].opacity != ~0U)        grays[(ssize_t) gray.opacity++].opacity=grays[i].opacity;  }  /*
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:67,


示例12: my_ntohs

//.........这里部分代码省略.........						if (mask[im]!=255){							bGoodMask=true;							break;						}					}					if (bGoodMask && c != 32){#if CXIMAGE_SUPPORT_ALPHA						bool bNeedAlpha = false;						if (!AlphaIsValid()){							AlphaCreate();						} else { 							bNeedAlpha=true; //32bit icon						}						int x,y;						for (y = 0; y < head.biHeight; y++) {							for (x = 0; x < head.biWidth; x++) {								if (((mask[y*maskwdt+(x>>3)]>>(7-x%8))&0x01)){									AlphaSet(x,y,0);									bNeedAlpha=true;								}							}						}						if (!bNeedAlpha) AlphaDelete();#endif //CXIMAGE_SUPPORT_ALPHA						//check if there is only one transparent color						RGBQUAD cc,ct;						long* pcc = (long*)&cc;						long* pct = (long*)&ct;						int nTransColors=0;						int nTransIndex=0;						for (y = 0; y < head.biHeight; y++){							for (x = 0; x < head.biWidth; x++){								if (((mask[y*maskwdt+(x>>3)] >> (7-x%8)) & 0x01)){									cc = GetPixelColor(x,y,false);									if (nTransColors==0){										nTransIndex = GetPixelIndex(x,y);										nTransColors++;										ct = cc;									} else {										if (*pct!=*pcc){											nTransColors++;										}									}								}							}						}						if (nTransColors==1){							SetTransColor(ct);							SetTransIndex(nTransIndex);#if CXIMAGE_SUPPORT_ALPHA							AlphaDelete(); //because we have a unique transparent color in the image#endif //CXIMAGE_SUPPORT_ALPHA						}						// <vho> - Transparency support w/o Alpha support						if (c <= 8){ // only for icons with less than 256 colors (XP icons need alpha).							  							// find a color index, which is not used in the image							// it is almost sure to find one, bcs. nobody uses all possible colors for an icon							BYTE colorsUsed[256];							memset(colorsUsed, 0, sizeof(colorsUsed));							for (y = 0; y < head.biHeight; y++){								for (x = 0; x < head.biWidth; x++){									colorsUsed[BlindGetPixelIndex(x,y)] = 1;								}							}							int iTransIdx = -1;							for (x = (int)(head.biClrUsed-1); x>=0 ; x--){								if (colorsUsed[x] == 0){									iTransIdx = x; // this one is not in use. we may use it as transparent color									break;								}							}							// Go thru image and set unused color as transparent index if needed							if (iTransIdx >= 0){								bool bNeedTrans = false;								for (y = 0; y < head.biHeight; y++){									for (x = 0; x < head.biWidth; x++){										// AND mask (Each Byte represents 8 Pixels)										if (((mask[y*maskwdt+(x>>3)] >> (7-x%8)) & 0x01)){											// AND mask is set (!=0). This is a transparent part											SetPixelIndex(x, y, (BYTE)iTransIdx);											bNeedTrans = true;										}									}								}								// set transparent index if needed								if (bNeedTrans)	SetTransIndex(iTransIdx);#if CXIMAGE_SUPPORT_ALPHA								AlphaDelete(); //because we have a transparent color in the palette#endif //CXIMAGE_SUPPORT_ALPHA							}						}					} else if(c != 32){
开发者ID:sd-eblana,项目名称:bawx,代码行数:101,


示例13: GetWandViewIterator

//.........这里部分代码省略.........%        const ssize_t y,const int thread_id,void *context)%%  Use this pragma if the view is not single threaded:%%    #pragma omp critical%%  to define a section of code in your callback get method that must be%  executed by a single thread at a time.%%  The format of the GetWandViewIterator method is:%%      MagickBooleanType GetWandViewIterator(WandView *source,%        GetWandViewMethod get,void *context)%%  A description of each parameter follows:%%    o source: the source wand view.%%    o get: the get callback method.%%    o context: the user defined context.%*/WandExport MagickBooleanType GetWandViewIterator(WandView *source,  GetWandViewMethod get,void *context){  Image    *source_image;  MagickBooleanType    status;  MagickOffsetType    progress;  ssize_t    y;  assert(source != (WandView *) NULL);  assert(source->signature == WandSignature);  if (get == (GetWandViewMethod) NULL)    return(MagickFalse);  source_image=source->wand->images;  status=MagickTrue;  progress=0;#if defined(MAGICKCORE_OPENMP_SUPPORT)  #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads)#endif  for (y=source->extent.y; y < (ssize_t) source->extent.height; y++)  {    const int      id = GetOpenMPThreadId();    register const IndexPacket      *indexes;    register const PixelPacket      *pixels;    register ssize_t      x;    if (status == MagickFalse)      continue;    pixels=GetCacheViewVirtualPixels(source->view,source->extent.x,y,      source->extent.width,1,source->exception);    if (pixels == (const PixelPacket *) NULL)      {        status=MagickFalse;        continue;      }    indexes=GetCacheViewVirtualIndexQueue(source->view);    for (x=0; x < (ssize_t) source->extent.width; x++)      PixelSetQuantumColor(source->pixel_wands[id][x],pixels+x);    if (source_image->colorspace == CMYKColorspace)      for (x=0; x < (ssize_t) source->extent.width; x++)        PixelSetBlackQuantum(source->pixel_wands[id][x],          GetPixelBlack(indexes+x));    if (source_image->storage_class == PseudoClass)      for (x=0; x < (ssize_t) source->extent.width; x++)        PixelSetIndex(source->pixel_wands[id][x],          GetPixelIndex(indexes+x));    if (get(source,y,id,context) == MagickFalse)      status=MagickFalse;    if (source_image->progress_monitor != (MagickProgressMonitor) NULL)      {        MagickBooleanType          proceed;#if defined(MAGICKCORE_OPENMP_SUPPORT)  #pragma omp critical (MagickWand_GetWandViewIterator)#endif        proceed=SetImageProgress(source_image,source->description,progress++,          source->extent.height);        if (proceed == MagickFalse)          status=MagickFalse;      }  }  return(status);}
开发者ID:ikbear,项目名称:ImageMagick,代码行数:101,


示例14: DuplexTransferWandViewIterator

//.........这里部分代码省略.........    register const PixelPacket      *restrict duplex_pixels,      *restrict pixels;    register IndexPacket      *restrict destination_indexes;    register ssize_t      x;    register PixelPacket      *restrict destination_pixels;    if (status == MagickFalse)      continue;    pixels=GetCacheViewVirtualPixels(source->view,source->extent.x,y,      source->extent.width,1,source->exception);    if (pixels == (const PixelPacket *) NULL)      {        status=MagickFalse;        continue;      }    indexes=GetCacheViewVirtualIndexQueue(source->view);    for (x=0; x < (ssize_t) source->extent.width; x++)      PixelSetQuantumColor(source->pixel_wands[id][x],pixels+x);    if (source_image->colorspace == CMYKColorspace)      for (x=0; x < (ssize_t) source->extent.width; x++)        PixelSetBlackQuantum(source->pixel_wands[id][x],          GetPixelBlack(indexes+x));    if (source_image->storage_class == PseudoClass)      for (x=0; x < (ssize_t) source->extent.width; x++)        PixelSetIndex(source->pixel_wands[id][x],          GetPixelIndex(indexes+x));    duplex_pixels=GetCacheViewVirtualPixels(duplex->view,duplex->extent.x,y,      duplex->extent.width,1,duplex->exception);    if (duplex_pixels == (const PixelPacket *) NULL)      {        status=MagickFalse;        continue;      }    duplex_indexes=GetCacheViewVirtualIndexQueue(duplex->view);    for (x=0; x < (ssize_t) duplex->extent.width; x++)      PixelSetQuantumColor(duplex->pixel_wands[id][x],duplex_pixels+x);    if (duplex_image->colorspace == CMYKColorspace)      for (x=0; x < (ssize_t) duplex->extent.width; x++)        PixelSetBlackQuantum(duplex->pixel_wands[id][x],          GetPixelBlack(duplex_indexes+x));    if (duplex_image->storage_class == PseudoClass)      for (x=0; x < (ssize_t) duplex->extent.width; x++)        PixelSetIndex(duplex->pixel_wands[id][x],          GetPixelIndex(duplex_indexes+x));    destination_pixels=GetCacheViewAuthenticPixels(destination->view,      destination->extent.x,y,destination->extent.width,1,exception);    if (destination_pixels == (PixelPacket *) NULL)      {        status=MagickFalse;        continue;      }    destination_indexes=GetCacheViewAuthenticIndexQueue(destination->view);    for (x=0; x < (ssize_t) destination->extent.width; x++)      PixelSetQuantumColor(destination->pixel_wands[id][x],        destination_pixels+x);    if (destination_image->colorspace == CMYKColorspace)      for (x=0; x < (ssize_t) destination->extent.width; x++)        PixelSetBlackQuantum(destination->pixel_wands[id][x],
开发者ID:ikbear,项目名称:ImageMagick,代码行数:67,


示例15: WritePCLImage

static MagickBooleanType WritePCLImage(const ImageInfo *image_info,Image *image,  ExceptionInfo *exception){  char    buffer[MaxTextExtent];  const char    *option;  MagickBooleanType    status;  MagickOffsetType    scene;  register const Quantum *p;  register ssize_t i, x;  register unsigned char *q;  size_t    density,    length,    one,    packets;  ssize_t    y;  unsigned char    bits_per_pixel,    *compress_pixels,    *pixels,    *previous_pixels;  /*    Open output image file.  */  assert(image_info != (const ImageInfo *) NULL);  assert(image_info->signature == MagickSignature);  assert(image != (Image *) NULL);  assert(image->signature == MagickSignature);  if (image->debug != MagickFalse)    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);  assert(exception != (ExceptionInfo *) NULL);  assert(exception->signature == MagickSignature);  status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);  if (status == MagickFalse)    return(status);  density=75;  if (image_info->density != (char *) NULL)    {      GeometryInfo        geometry;      (void) ParseGeometry(image_info->density,&geometry);      density=(size_t) geometry.rho;    }  scene=0;  one=1;  do  {    if (IsRGBColorspace(image->colorspace) == MagickFalse)      (void) TransformImageColorspace(image,RGBColorspace,exception);    /*      Initialize the printer.    */    (void) WriteBlobString(image,"/033E");  /* printer reset */    (void) WriteBlobString(image,"/033*r3F");  /* set presentation mode */    (void) FormatLocaleString(buffer,MaxTextExtent,"/033*r%.20gs%.20gT",      (double) image->columns,(double) image->rows);    (void) WriteBlobString(image,buffer);    (void) FormatLocaleString(buffer,MaxTextExtent,"/033*t%.20gR",(double)      density);    (void) WriteBlobString(image,buffer);    (void) WriteBlobString(image,"/033&l0E");  /* top margin 0 */    if (IsImageMonochrome(image,exception) != MagickFalse)      {        /*          Monochrome image: use default printer monochrome setup.        */        bits_per_pixel=1;      }    else      if (image->storage_class == DirectClass)        {          /*            DirectClass image.          */          bits_per_pixel=24;          (void) WriteBlobString(image,"/033*v6W"); /* set color mode */          (void) WriteBlobByte(image,0); /* RGB */          (void) WriteBlobByte(image,3); /* direct by pixel */          (void) WriteBlobByte(image,0); /* bits per index (ignored) */          (void) WriteBlobByte(image,8); /* bits per red component */          (void) WriteBlobByte(image,8); /* bits per green component */          (void) WriteBlobByte(image,8); /* bits per blue component */        }      else//.........这里部分代码省略.........
开发者ID:ChaseReid,项目名称:ImageMagick,代码行数:101,


示例16: GetPixelIndex

/** * HistogramStretch * /param method: 0 = luminance (default), 1 = linked channels , 2 = independent channels. * /return true if everything is ok * /author [dave] and [nipper] */bool CxImage::HistogramStretch(long method){  if (!pDib) return false;  if ((head.biBitCount==8) && IsGrayScale()){	// get min/max info	BYTE minc = 255, maxc = 0;	BYTE gray;	long y;	double dbScaler = 50.0/head.biHeight;	for (y=0; y<head.biHeight; y++)	{		info.nProgress = (long)(y*dbScaler);		for (long x=0; x<head.biWidth; x++)	{			gray = GetPixelIndex(x, y);			if (gray < minc)   minc = gray;			if (gray > maxc)   maxc = gray; 		}	}	if (minc == 0 && maxc == 255) return true;		// calculate LUT	BYTE lut[256];	BYTE range = maxc - minc;	if (range != 0){		for (long x = minc; x <= maxc; x++){			lut[x] = (BYTE)(255 * (x - minc) / range);		}	} else lut[minc] = minc;	for (y=0; y<head.biHeight; y++)	{		info.nProgress = (long)(50.0+y*dbScaler);		for (long x=0; x<head.biWidth; x++)		{			SetPixelIndex(x, y, lut[GetPixelIndex(x, y)]);		}	}  } else {	switch(method){	case 1:	  { // <nipper>		// get min/max info		BYTE minc = 255, maxc = 0;		RGBQUAD color;		long y;		for (y=0; y<head.biHeight; y++)		{			for (long x=0; x<head.biWidth; x++)			{				color = GetPixelColor(x, y);				if (color.rgbRed < minc)   minc = color.rgbRed;				if (color.rgbBlue < minc)  minc = color.rgbBlue;				if (color.rgbGreen < minc) minc = color.rgbGreen;				if (color.rgbRed > maxc)   maxc = color.rgbRed; 				if (color.rgbBlue > maxc)  maxc = color.rgbBlue; 				if (color.rgbGreen > maxc) maxc = color.rgbGreen; 			}		}		if (minc == 0 && maxc == 255)			return true;				// calculate LUT		BYTE lut[256];		BYTE range = maxc - minc;		if (range != 0){			for (long x = minc; x <= maxc; x++){				lut[x] = (BYTE)(255 * (x - minc) / range);			}		} else lut[minc] = minc;		// normalize image		double dbScaler = 100.0/head.biHeight;		for (y=0; y<head.biHeight; y++)	{			info.nProgress = (long)(y*dbScaler);			for (long x=0; x<head.biWidth; x++)			{				color = GetPixelColor(x, y);				color.rgbRed = lut[color.rgbRed];				color.rgbBlue = lut[color.rgbBlue];				color.rgbGreen = lut[color.rgbGreen];				SetPixelColor(x, y, color);//.........这里部分代码省略.........
开发者ID:JimLiu,项目名称:asptools,代码行数:101,


示例17: SortColormapByIntensity

MagickExport MagickBooleanType SortColormapByIntensity(Image *image,  ExceptionInfo *exception){  CacheView    *image_view;  MagickBooleanType    status;  register ssize_t    i;  ssize_t    y;  unsigned short    *pixels;  assert(image != (Image *) NULL);  if (image->debug != MagickFalse)    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");  assert(image->signature == MagickCoreSignature);  if (image->storage_class != PseudoClass)    return(MagickTrue);  /*    Allocate memory for pixel indexes.  */  pixels=(unsigned short *) AcquireQuantumMemory((size_t) image->colors,    sizeof(*pixels));  if (pixels == (unsigned short *) NULL)    ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",      image->filename);  /*    Assign index values to colormap entries.  */#if defined(MAGICKCORE_OPENMP_SUPPORT)  #pragma omp parallel for schedule(static,4) shared(status) /    magick_threads(image,image,1,1)#endif  for (i=0; i < (ssize_t) image->colors; i++)    image->colormap[i].alpha=(double) i;  /*    Sort image colormap by decreasing color popularity.  */  qsort((void *) image->colormap,(size_t) image->colors,    sizeof(*image->colormap),IntensityCompare);  /*    Update image colormap indexes to sorted colormap order.  */#if defined(MAGICKCORE_OPENMP_SUPPORT)  #pragma omp parallel for schedule(static,4) shared(status)#endif  for (i=0; i < (ssize_t) image->colors; i++)    pixels[(ssize_t) image->colormap[i].alpha]=(unsigned short) i;  status=MagickTrue;  image_view=AcquireAuthenticCacheView(image,exception);  for (y=0; y < (ssize_t) image->rows; y++)  {    Quantum      index;    register ssize_t      x;    register Quantum      *restrict q;    q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);    if (q == (Quantum *) NULL)      {        status=MagickFalse;        break;      }    for (x=0; x < (ssize_t) image->columns; x++)    {      index=(Quantum) pixels[(ssize_t) GetPixelIndex(image,q)];      SetPixelIndex(image,index,q);      SetPixelViaPixelInfo(image,image->colormap+(ssize_t) index,q);      q+=GetPixelChannels(image);    }    if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)      status=MagickFalse;    if (status == MagickFalse)      break;  }  image_view=DestroyCacheView(image_view);  pixels=(unsigned short *) RelinquishMagickMemory(pixels);  return(status);}
开发者ID:jeffasd,项目名称:ImageMagick,代码行数:89,


示例18: InverseFourier

static MagickBooleanType InverseFourier(FourierInfo *fourier_info,  const Image *magnitude_image,const Image *phase_image,fftw_complex *fourier,  ExceptionInfo *exception){  CacheView    *magnitude_view,    *phase_view;  double    *magnitude,    *phase,    *magnitude_source,    *phase_source;  MagickBooleanType    status;  register const IndexPacket    *indexes;  register const PixelPacket    *p;  register ssize_t    i,    x;  ssize_t    y;  /*    Inverse fourier - read image and break down into a double array.  */  magnitude_source=(double *) AcquireQuantumMemory((size_t)    fourier_info->height,fourier_info->width*sizeof(*magnitude_source));  if (magnitude_source == (double *) NULL)    {      (void) ThrowMagickException(exception,GetMagickModule(),        ResourceLimitError,"MemoryAllocationFailed","`%s'",        magnitude_image->filename);      return(MagickFalse);    }  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'",        magnitude_image->filename);      magnitude_source=(double *) RelinquishMagickMemory(magnitude_source);      return(MagickFalse);    }  i=0L;  magnitude_view=AcquireVirtualCacheView(magnitude_image,exception);  for (y=0L; y < (ssize_t) fourier_info->height; y++)  {    p=GetCacheViewVirtualPixels(magnitude_view,0L,y,fourier_info->width,1UL,      exception);    if (p == (const PixelPacket *) NULL)      break;    indexes=GetCacheViewAuthenticIndexQueue(magnitude_view);    for (x=0L; x < (ssize_t) fourier_info->width; x++)    {      switch (fourier_info->channel)      {        case RedChannel:        default:        {          magnitude_source[i]=QuantumScale*GetPixelRed(p);          break;        }        case GreenChannel:        {          magnitude_source[i]=QuantumScale*GetPixelGreen(p);          break;        }        case BlueChannel:        {          magnitude_source[i]=QuantumScale*GetPixelBlue(p);          break;        }        case OpacityChannel:        {          magnitude_source[i]=QuantumScale*GetPixelOpacity(p);          break;        }        case IndexChannel:        {          magnitude_source[i]=QuantumScale*GetPixelIndex(indexes+x);          break;        }        case GrayChannels:        {          magnitude_source[i]=QuantumScale*GetPixelGray(p);          break;        }      }      i++;      p++;    }//.........这里部分代码省略.........
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:101,


示例19: WritePS2Image

//.........这里部分代码省略.........                  break;                indexes=GetVirtualIndexQueue(image);                for (x=0; x < (ssize_t) image->columns; x++)                {                  if ((image->matte != MagickFalse) &&                      (GetPixelOpacity(p) == (Quantum) TransparentOpacity))                    {                      Ascii85Encode(image,ScaleQuantumToChar((Quantum)                        QuantumRange));                      Ascii85Encode(image,ScaleQuantumToChar((Quantum)                        QuantumRange));                      Ascii85Encode(image,ScaleQuantumToChar((Quantum)                        QuantumRange));                    }                  else                    if (image->colorspace != CMYKColorspace)                      {                        Ascii85Encode(image,ScaleQuantumToChar(                          GetPixelRed(p)));                        Ascii85Encode(image,ScaleQuantumToChar(                          GetPixelGreen(p)));                        Ascii85Encode(image,ScaleQuantumToChar(                          GetPixelBlue(p)));                      }                    else                      {                        Ascii85Encode(image,ScaleQuantumToChar(                          GetPixelRed(p)));                        Ascii85Encode(image,ScaleQuantumToChar(                          GetPixelGreen(p)));                        Ascii85Encode(image,ScaleQuantumToChar(                          GetPixelBlue(p)));                        Ascii85Encode(image,ScaleQuantumToChar(                          GetPixelIndex(indexes+x)));                      }                  p++;                }                progress=SetImageProgress(image,SaveImageTag,(MagickOffsetType)                  y,image->rows);                if (progress == MagickFalse)                  break;              }              Ascii85Flush(image);              break;            }          }        }      else        {          /*            Dump number of colors and colormap.          */          (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g %.20g/n1/n%d/n",            (double) image->columns,(double) image->rows,(int)            (image->colorspace == CMYKColorspace));          (void) WriteBlobString(image,buffer);          (void) FormatLocaleString(buffer,MaxTextExtent,"%d/n",            (int) (compression == NoCompression));          (void) WriteBlobString(image,buffer);          (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g/n",(double)            image->colors);          (void) WriteBlobString(image,buffer);          for (i=0; i < (ssize_t) image->colors; i++)          {            (void) FormatLocaleString(buffer,MaxTextExtent,"%02X%02X%02X/n",              ScaleQuantumToChar(image->colormap[i].red),
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:67,


示例20: 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);    }
开发者ID:DINKIN,项目名称:ImageMagick,代码行数:101,


示例21: memset

bool CxImagePCX::Encode(CxFile * hFile){	if (EncodeSafeCheck(hFile)) return false;  try {	PCXHEADER pcxHeader;	memset(&pcxHeader,0,sizeof(pcxHeader));	pcxHeader.Manufacturer = PCX_MAGIC;	pcxHeader.Version = 5;	pcxHeader.Encoding = 1;	pcxHeader.Xmin = 0;	pcxHeader.Ymin = 0;	pcxHeader.Xmax = (WORD)head.biWidth-1;	pcxHeader.Ymax = (WORD)head.biHeight-1;	pcxHeader.Hres = (WORD)info.xDPI;	pcxHeader.Vres = (WORD)info.yDPI;	pcxHeader.Reserved = 0;	pcxHeader.PaletteType = head.biClrUsed==0;	switch(head.biBitCount){	case 24:	case 8:		{			pcxHeader.BitsPerPixel = 8;			pcxHeader.ColorPlanes = head.biClrUsed==0 ? 3 : 1;#if CXIMAGE_SUPPORT_ALPHA			if (AlphaIsValid() && head.biClrUsed==0) pcxHeader.ColorPlanes =4;#endif //CXIMAGE_SUPPORT_ALPHA			pcxHeader.BytesPerLine = (WORD)head.biWidth;			break;		}	default: //(4 1)		pcxHeader.BitsPerPixel = 1;		pcxHeader.ColorPlanes = head.biClrUsed==16 ? 4 : 1;		pcxHeader.BytesPerLine = (WORD)((head.biWidth * pcxHeader.BitsPerPixel + 7)>>3);	}    if (pcxHeader.BitsPerPixel == 1 && pcxHeader.ColorPlanes == 1){		pcxHeader.ColorMap[0][0] = pcxHeader.ColorMap[0][1] = pcxHeader.ColorMap[0][2] = 0;		pcxHeader.ColorMap[1][0] = pcxHeader.ColorMap[1][1] = pcxHeader.ColorMap[1][2] = 255;	}	if (pcxHeader.BitsPerPixel == 1 && pcxHeader.ColorPlanes == 4){		RGBQUAD c;		for (int i = 0; i < 16; i++){			c=GetPaletteColor(i);			pcxHeader.ColorMap[i][0] = c.rgbRed;			pcxHeader.ColorMap[i][1] = c.rgbGreen;			pcxHeader.ColorMap[i][2] = c.rgbBlue;		}	}	pcxHeader.BytesPerLine = (pcxHeader.BytesPerLine + 1)&(~1);	if (hFile->Write(&pcxHeader, sizeof(pcxHeader), 1) == 0 )	   throw "cannot write PCX header";	CxMemFile buffer;	buffer.Open();	BYTE c,n;	long x,y;	if (head.biClrUsed==0){		for (y = head.biHeight-1; y >=0 ; y--){			for (int p=0; p<pcxHeader.ColorPlanes; p++){				c=n=0;				for (x = 0; x<head.biWidth; x++){					if (p==0)						PCX_PackPixels(GetPixelColor(x,y).rgbRed,c,n,buffer);					else if (p==1)						PCX_PackPixels(GetPixelColor(x,y).rgbGreen,c,n,buffer);					else if (p==2)						PCX_PackPixels(GetPixelColor(x,y).rgbBlue,c,n,buffer);#if CXIMAGE_SUPPORT_ALPHA					else if (p==3)						PCX_PackPixels(AlphaGet(x,y),c,n,buffer);#endif //CXIMAGE_SUPPORT_ALPHA				}				PCX_PackPixels(-1-(head.biWidth&0x1),c,n,buffer);			}		}		hFile->Write(buffer.GetBuffer(false),buffer.Size(),1);	} else if (head.biBitCount==8) {		for (y = head.biHeight-1; y >=0 ; y--){			c=n=0;			for (x = 0; x<head.biWidth; x++){				PCX_PackPixels(GetPixelIndex(x,y),c,n,buffer);			}			PCX_PackPixels(-1-(head.biWidth&0x1),c,n,buffer);		}		hFile->Write(buffer.GetBuffer(false),buffer.Size(),1);		if (head.biBitCount == 8){			hFile->PutC(0x0C);			BYTE* pal = (BYTE*)malloc(768);			RGBQUAD c;			for (int i=0;i<256;i++){//.........这里部分代码省略.........
开发者ID:AnthonyNystrom,项目名称:GenXSource,代码行数:101,


示例22: WritePICONImage

//.........这里部分代码省略.........          break;        indexes=GetAuthenticIndexQueue(picon);        for (x=0; x < (ssize_t) picon->columns; x++)        {          if (q->opacity == (Quantum) TransparentOpacity)            SetPixelIndex(indexes+x,picon->colors);          q++;        }        if (SyncAuthenticPixels(picon,exception) == MagickFalse)          break;      }    }  /*    Compute the character per pixel.  */  characters_per_pixel=1;  for (k=MaxCixels; (ssize_t) colors > k; k*=MaxCixels)    characters_per_pixel++;  /*    XPM header.  */  (void) WriteBlobString(image,"/* XPM *//n");  GetPathComponent(picon->filename,BasePath,basename);  (void) FormatLocaleString(buffer,MaxTextExtent,    "static char *%s[] = {/n",basename);  (void) WriteBlobString(image,buffer);  (void) WriteBlobString(image,"/* columns rows colors chars-per-pixel *//n");  (void) FormatLocaleString(buffer,MaxTextExtent,    "/"%.20g %.20g %.20g %.20g/",/n",(double) picon->columns,(double)    picon->rows,(double) colors,(double) characters_per_pixel);  (void) WriteBlobString(image,buffer);  GetMagickPixelPacket(image,&pixel);  for (i=0; i < (ssize_t) colors; i++)  {    /*      Define XPM color.    */    SetMagickPixelPacket(image,picon->colormap+i,(IndexPacket *) NULL,&pixel);    pixel.colorspace=sRGBColorspace;    pixel.depth=8;    pixel.opacity=(MagickRealType) OpaqueOpacity;    (void) QueryMagickColorname(image,&pixel,XPMCompliance,name,      &image->exception);    if (transparent != MagickFalse)      {        if (i == (ssize_t) (colors-1))          (void) CopyMagickString(name,"grey75",MaxTextExtent);      }    /*      Write XPM color.    */    k=i % MaxCixels;    symbol[0]=Cixel[k];    for (j=1; j < (ssize_t) characters_per_pixel; j++)    {      k=((i-k)/MaxCixels) % MaxCixels;      symbol[j]=Cixel[k];    }    symbol[j]='/0';    (void) FormatLocaleString(buffer,MaxTextExtent,"/"%s c %s/",/n",       symbol,name);    (void) WriteBlobString(image,buffer);  }  /*    Define XPM pixels.  */  (void) WriteBlobString(image,"/* pixels *//n");  for (y=0; y < (ssize_t) picon->rows; y++)  {    p=GetVirtualPixels(picon,0,y,picon->columns,1,&picon->exception);    if (p == (const PixelPacket *) NULL)      break;    indexes=GetVirtualIndexQueue(picon);    (void) WriteBlobString(image,"/"");    for (x=0; x < (ssize_t) picon->columns; x++)    {      k=((ssize_t) GetPixelIndex(indexes+x) % MaxCixels);      symbol[0]=Cixel[k];      for (j=1; j < (ssize_t) characters_per_pixel; j++)      {        k=(((int) GetPixelIndex(indexes+x)-k)/MaxCixels) % MaxCixels;        symbol[j]=Cixel[k];      }      symbol[j]='/0';      (void) CopyMagickString(buffer,symbol,MaxTextExtent);      (void) WriteBlobString(image,buffer);    }    (void) FormatLocaleString(buffer,MaxTextExtent,"/"%s/n",      y == (ssize_t) (picon->rows-1) ? "" : ",");    (void) WriteBlobString(image,buffer);    status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,      picon->rows);    if (status == MagickFalse)      break;  }  picon=DestroyImage(picon);  (void) WriteBlobString(image,"};/n");  (void) CloseBlob(image);  return(MagickTrue);}
开发者ID:MarinaAndenko,项目名称:MyBlog,代码行数:101,


示例23: strcpy

bool CxImageJ2K::Encode(CxFile * hFile){	if (EncodeSafeCheck(hFile)) return false;	if (head.biClrUsed!=0 && !IsGrayScale()){		strcpy(info.szLastError,"J2K can save only RGB or GrayScale images");		return false;	}    int i,x,y;    j2k_image_t *img;    j2k_cp_t *cp;    j2k_tcp_t *tcp;    j2k_tccp_t *tccp;	img = (j2k_image_t *)calloc(sizeof(j2k_image_t),1);	cp = (j2k_cp_t *)calloc(sizeof(j2k_cp_t),1);    cp->tx0=0; cp->ty0=0;    cp->tw=1; cp->th=1;    cp->tcps=(j2k_tcp_t*)calloc(sizeof(j2k_tcp_t),1);    tcp=&cp->tcps[0];	long w=head.biWidth;	long h=head.biHeight; 	tcp->numlayers=1;	for (i=0;i<tcp->numlayers;i++) tcp->rates[i]=(w*h*GetJpegQuality())/600;    if (IsGrayScale()) {        img->x0=0;		img->y0=0;		img->x1=w;		img->y1=h;        img->numcomps=1;        img->comps=(j2k_comp_t*)calloc(sizeof(j2k_comp_t),1);        img->comps[0].data=(int*)calloc(w*h*sizeof(int),1);        img->comps[0].prec=8;        img->comps[0].sgnd=0;        img->comps[0].dx=1;        img->comps[0].dy=1;		for (i=0,y=0; y<h; y++) {			for (x=0; x<w; x++,i++){				img->comps[0].data[i]=GetPixelIndex(x,h-1-y);			}		}    } else if (!IsIndexed()) {        img->x0=0;		img->y0=0;		img->x1=w;		img->y1=h;        img->numcomps=3;        img->comps=(j2k_comp_t*)calloc(img->numcomps*sizeof(j2k_comp_t),1);        for (i=0; i<img->numcomps; i++) {            img->comps[i].data=(int*)calloc(w*h*sizeof(int),1);            img->comps[i].prec=8;            img->comps[i].sgnd=0;            img->comps[i].dx=1;            img->comps[i].dy=1;        }		RGBQUAD c;        for (i=0,y=0; y<h; y++) {			for (x=0; x<w; x++,i++){				c=GetPixelColor(x,h-1-y);				img->comps[0].data[i]=c.rgbRed;				img->comps[1].data[i]=c.rgbGreen;				img->comps[2].data[i]=c.rgbBlue;			}		}    } else {        return 0;    }	    cp->tdx=img->x1-img->x0;	cp->tdy=img->y1-img->y0;    tcp->csty=0;    tcp->prg=0;    tcp->mct=img->numcomps==3?1:0;    tcp->tccps=(j2k_tccp_t*)calloc(img->numcomps*sizeof(j2k_tccp_t),1);    int ir=0; /* or 1 ???*/    for (i=0; i<img->numcomps; i++) {        tccp=&tcp->tccps[i];        tccp->csty=0;        tccp->numresolutions=6;        tccp->cblkw=6;        tccp->cblkh=6;        tccp->cblksty=0;        tccp->qmfbid=ir?0:1;        tccp->qntsty=ir?J2K_CCP_QNTSTY_SEQNT:J2K_CCP_QNTSTY_NOQNT;        tccp->numgbits=2;        tccp->roishift=0;        j2k_calc_explicit_stepsizes(tccp, img->comps[i].prec);    }    BYTE* dest=(BYTE*)calloc(tcp->rates[tcp->numlayers-1]+2,1);    long len = j2k_encode(img, cp, dest, tcp->rates[tcp->numlayers-1]+2);//.........这里部分代码省略.........
开发者ID:gotoshake,项目名称:quick-cc,代码行数:101,


示例24: 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,


示例25: GetClipBox

////////////////////////////////////////////////////////////////////////////////// Draws (stretch) the image with transparency & alpha support// > hdc: destination device context// > x,y: (optional) offset// > cx,cy: (optional) size.long CxImage::Draw(HDC hdc, long x, long y, long cx, long cy, RECT* pClipRect){	if((pDib==0)||(hdc==0)||(cx==0)||(cy==0)||(!info.bEnabled)) return 0;	if (cx < 0) cx = head.biWidth;	if (cy < 0) cy = head.biHeight;	bool bTransparent = info.nBkgndIndex != -1;	bool bAlpha = pAlpha != 0;	RECT mainbox; // (experimental) 	if (pClipRect){		GetClipBox(hdc,&mainbox);		HRGN rgn = CreateRectRgnIndirect(pClipRect);		ExtSelectClipRgn(hdc,rgn,RGN_AND);		DeleteObject(rgn);	}	if (!(bTransparent || bAlpha || info.bAlphaPaletteEnabled)){		if (cx==head.biWidth && cy==head.biHeight){ //NORMAL			SetStretchBltMode(hdc,COLORONCOLOR);				SetDIBitsToDevice(hdc, x, y, cx, cy, 0, 0, 0, cy,						info.pImage,(BITMAPINFO*)pDib,DIB_RGB_COLORS);		} else { //STRETCH			RECT clipbox,paintbox;			GetClipBox(hdc,&clipbox);			paintbox.left = min(clipbox.right,max(clipbox.left,x));			paintbox.right = max(clipbox.left,min(clipbox.right,x+cx));			paintbox.top = min(clipbox.bottom,max(clipbox.top,y));			paintbox.bottom = max(clipbox.top,min(clipbox.bottom,y+cy));			long destw = paintbox.right - paintbox.left;			long desth = paintbox.bottom - paintbox.top;			//pixel informations			RGBQUAD c={0,0,0,0};			//Preparing Bitmap Info			BITMAPINFO bmInfo;			memset(&bmInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));			bmInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);			bmInfo.bmiHeader.biWidth=destw;			bmInfo.bmiHeader.biHeight=desth;			bmInfo.bmiHeader.biPlanes=1;			bmInfo.bmiHeader.biBitCount=24;			BYTE *pbase;	//points to the final dib			BYTE *pdst;		//current pixel from pbase			BYTE *ppix;		//current pixel from image			//get the background			HDC TmpDC=CreateCompatibleDC(hdc);			HBITMAP TmpBmp=CreateDIBSection(hdc,&bmInfo,DIB_RGB_COLORS,(void**)&pbase,0,0);			HGDIOBJ TmpObj=SelectObject(TmpDC,TmpBmp);			if (pbase){				long xx,yy,yoffset;				long ew = ((((24 * destw) + 31) / 32) * 4);				long ymax = paintbox.bottom;				long xmin = paintbox.left;				float fx=(float)head.biWidth/(float)cx;				float fy=(float)head.biHeight/(float)cy;				long sx,sy;				for(yy=0;yy<desth;yy++){					sy=max(0L,head.biHeight-(long)ceil(((ymax-yy-y)*fy)));					yoffset=sy*head.biWidth;					pdst=pbase+yy*ew;					for(xx=0;xx<destw;xx++){						sx=(long)floor(((xx+xmin-x)*fx));						if (head.biClrUsed){							c=GetPaletteColor(GetPixelIndex(sx,sy));						} else {							ppix=info.pImage+sy*info.dwEffWidth+sx*3;							c.rgbBlue = *ppix++;							c.rgbGreen= *ppix++;							c.rgbRed  = *ppix;						}						*pdst++=c.rgbBlue;						*pdst++=c.rgbGreen;						*pdst++=c.rgbRed;					}				}			}			//paint the image & cleanup			SetDIBitsToDevice(hdc,paintbox.left,paintbox.top,destw,desth,0,0,0,desth,pbase,&bmInfo,0);			DeleteObject(SelectObject(TmpDC,TmpObj));			DeleteDC(TmpDC);		}	} else {	// draw image with transparent/alpha blending	//////////////////////////////////////////////////////////////////		//Alpha blend - Thanks to Florian Egel		//find the smallest area to paint		RECT clipbox,paintbox;		GetClipBox(hdc,&clipbox);		paintbox.left = min(clipbox.right,max(clipbox.left,x));		paintbox.right = max(clipbox.left,min(clipbox.right,x+cx));		paintbox.top = min(clipbox.bottom,max(clipbox.top,y));		paintbox.bottom = max(clipbox.top,min(clipbox.bottom,y+cy));		long destw = paintbox.right - paintbox.left;		long desth = paintbox.bottom - paintbox.top;//.........这里部分代码省略.........
开发者ID:axxapp,项目名称:winxgui,代码行数:101,



注:本文中的GetPixelIndex函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ GetPixelRed函数代码示例
C++ GetPixelGreen函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。