Пример #1
0
//---------------------------------------------------------------------------
void __fastcall TMainForm::UpdatePanel2()
{
    unsigned char red,green,blue;
    try
    {
        red   = StrToInt(this->LabeledEdit1->Text);
        green = StrToInt(this->LabeledEdit2->Text);
        blue  = StrToInt(this->LabeledEdit3->Text);
    }
    catch(...)
    {
        return;
    }
    this->Panel2->Color = (TColor)RGB(red, green, blue);

    TPantoneColorEntry pe =  RGB2Pantone(red, green, blue);
    double d = sqrt((red - pe.Red)*(red - pe.Red) +
                    (green - pe.Green)*(green - pe.Green) +
                    (blue - pe.Blue)*(blue - pe.Blue));

    Label21->Caption = "d = " + FormatFloat(".000", d);

    CalculateColors();
}
Пример #2
0
static MagickBooleanType ReadDXT1(Image *image, DDSInfo *dds_info)
{
  DDSColors
    colors;

  ExceptionInfo
    *exception;

  PixelPacket
    *q;
  
  register ssize_t
    i,
    x;
  
  size_t
    bits;

  ssize_t
    j,
    y;
  
  unsigned char
    code;
  
  unsigned short
    c0,
    c1;
  
  exception=(&image->exception);
  for (y = 0; y < (ssize_t) dds_info->height; y += 4)
  {
    for (x = 0; x < (ssize_t) dds_info->width; x += 4)
    {
      /* Get 4x4 patch of pixels to write on */
      q = QueueAuthenticPixels(image, x, y, Min(4, dds_info->width - x),
        Min(4, dds_info->height - y),exception);
      
      if (q == (PixelPacket *) NULL)
        return MagickFalse;
      
      /* Read 8 bytes of data from the image */
      c0 = ReadBlobLSBShort(image);
      c1 = ReadBlobLSBShort(image);
      bits = ReadBlobLSBLong(image);
      
      CalculateColors(c0, c1, &colors, MagickFalse);
      
      /* Write the pixels */
      for (j = 0; j < 4; j++)
      {
        for (i = 0; i < 4; i++)
        {
          if ((x + i) < (ssize_t) dds_info->width && (y + j) < (ssize_t) dds_info->height)
            {
              code = (unsigned char) ((bits >> ((j*4+i)*2)) & 0x3);
              SetPixelRed(q,ScaleCharToQuantum(colors.r[code]));
              SetPixelGreen(q,ScaleCharToQuantum(colors.g[code]));
              SetPixelBlue(q,ScaleCharToQuantum(colors.b[code]));
              SetPixelOpacity(q,ScaleCharToQuantum(colors.a[code]));
              if (colors.a[code] && image->matte == MagickFalse)
                /* Correct matte */
                image->matte = MagickTrue;
              q++;
            }
        }
      }
      
      if (SyncAuthenticPixels(image,exception) == MagickFalse)
        return MagickFalse;
    }
  }
Пример #3
0
static MagickBooleanType ReadDXT1(Image *image, DDSInfo *dds_info)
{
    DDSColors
    colors;

    long
    j,
    y;

    PixelPacket
    *q;

    register long
    i,
    x;

    unsigned char
    code;

    unsigned short
    c0,
    c1;

    unsigned long
    bits;

    for (y = 0; y < (long) dds_info->height; y += 4)
    {
        for (x = 0; x < (long) dds_info->width; x += 4)
        {
            /* Get 4x4 patch of pixels to write on */
            q = SetImagePixels(image, x, y, Min(4, dds_info->width - x),
                               Min(4, dds_info->height - y));

            if (q == (PixelPacket *) NULL)
                return MagickFalse;

            /* Read 8 bytes of data from the image */
            c0 = ReadBlobLSBShort(image);
            c1 = ReadBlobLSBShort(image);
            bits = ReadBlobLSBLong(image);

            CalculateColors(c0, c1, &colors, MagickFalse);

            /* Write the pixels */
            for (j = 0; j < 4; j++)
            {
                for (i = 0; i < 4; i++)
                {
                    if ((x + i) < (long) dds_info->width && (y + j) < (long) dds_info->height)
                    {
                        code = (unsigned char) ((bits >> ((j*4+i)*2)) & 0x3);
                        q->red     = ScaleCharToQuantum( colors.r[code] );
                        q->green   = ScaleCharToQuantum( colors.g[code] );
                        q->blue    = ScaleCharToQuantum( colors.b[code] );
                        q->opacity = ScaleCharToQuantum( colors.a[code] );
                        if (colors.a[code] && image->matte == MagickFalse)
                            /* Correct matte */
                            image->matte = MagickTrue;
                        q++;
                    }
                }
            }

            if (SyncImagePixels(image) == MagickFalse)
                return MagickFalse;
        }
    }