void COLOURS_PAL_Update(int colourtable[256])
{
	if (COLOURS_PAL_external.loaded)
		AdjustExternal(colourtable);
	else
		GeneratePalette(colourtable);
}
Esempio n. 2
0
void WIZARD::SetGraphic (int idbGraphic16, int idbGraphic256)
{
   LPRGBQUAD pargb = NULL;
   RGBQUAD argb[256];

   m_idbGraphic16 = idbGraphic16;
   m_idbGraphic256 = idbGraphic256;

   if (m_bmpGraphic16 != NULL)
      {
      DeleteObject (m_bmpGraphic16);
      m_bmpGraphic16 = NULL;
      }

   if (m_bmpGraphic256 != NULL)
      {
      DeleteObject (m_bmpGraphic256);
      m_bmpGraphic256 = NULL;
      }

   if (m_palGraphic != NULL)
      {
      DeleteObject (m_palGraphic);
      m_palGraphic = NULL;
      }

   m_bmpGraphic16 = (HBITMAP)TaLocale_LoadImage (idbGraphic16, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);

   if ((m_bmpGraphic256 = (HBITMAP)TaLocale_LoadImage (idbGraphic256, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION)) != NULL)
      {
      BITMAP bm;
      GetObject (m_bmpGraphic256, sizeof(BITMAP), &bm);

      if ((bm.bmBitsPixel * bm.bmPlanes) == 8)
         {
         HDC hdc = CreateCompatibleDC (NULL);
         HBITMAP bmpOld = (HBITMAP)SelectObject (hdc, m_bmpGraphic256);

         GetDIBColorTable (hdc, 0, 256, argb);
         pargb = argb;

         SelectObject (hdc, bmpOld);
         DeleteDC (hdc);
         }
      }

   GeneratePalette (pargb);

   if (m_fShowing)
      {
      Refresh (REFRESH_LEFT_PANE);
      }
}
Esempio n. 3
0
WIZARD::WIZARD (void)
{
   m_iddTemplate = -1;
   m_idcLeftPane = -1;
   m_idcRightPane = -1;
   m_idcBack = -1;
   m_idcNext = -1;
   m_idbGraphic16 = -1;
   m_bmpGraphic16 = NULL;
   m_idbGraphic256 = -1;
   m_bmpGraphic256 = NULL;
   m_palGraphic = NULL;
   m_aStates = NULL;
   m_cStates = 0;
   m_stCurrent = -1;
   m_fShowing = FALSE;
   m_hWnd = NULL;

   m_iddBackground = -1;
   m_hBkg = NULL;
   m_fBlue = TRUE;
   m_fnBackground = NULL;
   m_szBackground[0] = TEXT('\0');
   m_bmpBackground = NULL;
   m_pfnCallback = NULL;
   m_bmpBuffer = NULL;
   SetRectEmpty (&m_rBuffer);

   HDC hdc = GetDC (NULL);
   LOGFONT lf;
   memset (&lf, 0x00, sizeof(lf));
   GetObject (GetStockObject (DEFAULT_GUI_FONT), sizeof(lf), &lf);
   lf.lfHeight = -MulDiv (cptWASH_TEXT_SIZE, GetDeviceCaps (hdc, LOGPIXELSY), 72);
   lf.lfWidth = 0;
   m_hfBackground = CreateFontIndirect (&lf);
   ReleaseDC (NULL, hdc);

   GeneratePalette();
}
Esempio n. 4
0
// ConvertTypeTo()
//  Converts the image from it's current type to the new type.  This
//   is NOT an in-place operation; rather, it creates and returns a
//   new ImageClass, which must be freed by the main program.  The
//   original ImageClass is not modified in any way.  For conversion
//   to indexed images, an optional palette can also be passed in.
//   Images will be quantized to match the palette as needed.
//   This function is most useful for image savers and device-dependant
//   output of images.
//  Note that if the source image doesn't need to be converted, this
//   function will return a pointer to the existing image class, so
//   be sure to check for this.  A returned value of NULL means some
//   error occured
ImageClass * ImageClass::ConvertTypeTo( int new_type,
                                        int num_reg, IMG_BYTE *pal ) {
  if( new_type == IMAGE_INVALID_TYPE )      // Invalid type; fail
    return NULL;

  if( new_type == type )                   // Already in the new mode; return this image
    return this;

  ImageClass * new_image = NULL;
  int x, y;
  IMG_BYTE       *new_pal;
  const IMG_BYTE *rgb;
  IMG_BYTE        value;

  switch( new_type ) {
  case IMAGE_RGB:       // Convert to RGB
    new_image = new ImageClass( width, height, IMAGE_RGB );
    if( !new_image || !(*new_image) ) {
      SetErrorState( IMAGE_OUT_OF_RAM );
      delete new_image;
      return NULL;
    }

    for( y=0; y < height; y++ ) {
      for( x=0; x < width; x++ ) {
        rgb = GetRGBAt( x, y );
        new_image->SetRGBAt( x, y, rgb );
      }
    }

    return new_image;
    break;

  case IMAGE_RGBA:      // Convert to RGBA
    new_image = new ImageClass( width, height, IMAGE_RGBA );
    if( !new_image || !(*new_image) ) {
      SetErrorState( IMAGE_OUT_OF_RAM );
      delete new_image;
      return NULL;
    }

    for( y=0; y < height; y++ ) {
      for( x=0; x < width; x++ ) {
        rgb = GetRGBAt( x, y );
        new_image->SetRGBAt( x, y, rgb );
      }
    }
    new_image->ClearAlpha();

    return new_image;
    break;

  case IMAGE_GREY:      // Convert to Greyscale
    new_image = new ImageClass( width, height, IMAGE_GREY );
    if( !new_image || !(*new_image) ) {
      SetErrorState( IMAGE_OUT_OF_RAM );
      delete new_image;
      return NULL;
    }

    for( y=0; y < height; y++ ) {
      for( x=0; x < width; x++ ) {
        value = GetValueAt( x, y );
        new_image->SetValueAt( x, y, value );
      }
    }

    return new_image;
    break;
  
  case IMAGE_INDEXED:   // Convert to Indexed
    new_image = new ImageClass( width, height, IMAGE_INDEXED, num_reg );
    if( !new_image || !(*new_image) ) {
      SetErrorState( IMAGE_OUT_OF_RAM );
      delete new_image;
      return NULL;
    }

    if( pal != NULL )   // Copy the new palette in, if applicable
      new_image->CopyPaletteFrom( pal );
    else if ( type == IMAGE_GREY ) {  // Generate a greyscale palette
      for( int i=0; i < 256; i++ ) {
        new_image->SetPaletteColor( i, i, i, i );
      }
    } else {              // Auto-generate a palette, if needed.
      new_pal = GeneratePalette( num_reg );
      new_image->CopyPaletteFrom( new_pal );
      delete new_pal;
    }

    for( y=0; y < height; y++ ) {
      for( x=0; x < width; x++ ) {
        if( type == IMAGE_GREY )
          value = GetValueAt( x, y );
        else {
          rgb   = GetRGBAt( x, y );
          value = new_image->FindPaletteIndex( rgb, 0, num_registers-1 );  // low/high must be a char, hence the -1.
        }

        new_image->SetPaletteIndexAt( x, y, value );
      }
    }

    return new_image;
    break;
  
  default:
    return NULL;
  }

}