示例#1
0
long* imPaletteHotIron(void)
{
  long* palette = imPaletteNew(256);
  long* ct = palette;
  int lIndex, lSubIndex;

  for (lIndex = 0, lSubIndex = 0; lSubIndex < 128; lSubIndex++, lIndex += 2)
  {
    /* From (0, 0, 0) to (254, 0, 0) */
    /* From   Black   to     ~Red    */
    *(ct++) = imColorEncode((imbyte)lIndex, 0, 0);
  }

  for (lIndex = 0, lSubIndex = 0; lSubIndex < 64; lSubIndex++, lIndex += 2)
  {
    /* From (255, 0, 0) to (255, 126, 0) */
    /* From      Red    to     ~Orange  */
    *(ct++) = imColorEncode(255, (imbyte)lIndex, 0);
  }

  for (lIndex = 0, lSubIndex = 0; lSubIndex < 63; lSubIndex++, lIndex += 2)
  {
    /* From (255, 128, 0) to (255, 252, 252)*/
    /* From     Orange    to     ~White   */
    imbyte red = 255;
    imbyte green = (imbyte)(128 + lIndex);
    imbyte blue = (imbyte)(lIndex * 2 + 4);

    *(ct++) = imColorEncode(red, green, blue);
  }

  *(ct++) = imColorEncode(255, 255, 255);

  return palette;
}
示例#2
0
long* imPaletteLinear(void)
{
  long* palette = imPaletteNew(256);
  long* ct = palette;
  int lIndex, lHue;
  unsigned char r, g, b;

  for (lIndex = 0; lIndex < 256; lIndex += 8)
  {
    float intensity = lIndex / 256.0f;

    for (lHue = 0; lHue < 8; lHue++)
    {
      float hue = (lHue * 360.0f) / 8.0f;

      imColorHSI2RGBbyte(hue, 1.0f, intensity, &r, &g, &b);

      *(ct++) = imColorEncode(r, g, b);
    }
  }

#if 0
  for (lIndex = 0; lIndex < 256; lIndex++)
  {
    float norm = (float)lIndex / 256.0f;
    imColorHSI2RGBbyte(norm * 360, 1.0f, norm, &r, &g, &b);

    *(ct++) = imColorEncode(r, g, b);
  }
#endif

  return palette;
}
示例#3
0
long* imPaletteBlackBody(void)
{
  long* palette = imPaletteNew(256);
  long* ct = palette;
  int lIndex, lSubIndex;

  for (lIndex = 0, lSubIndex = 0; lSubIndex < 85; lSubIndex++, lIndex += 3)
  {
    /* From (0, 0, 0) to (252, 0, 0) */
    /* From   Black   to     ~Red   */
    *(ct++) = imColorEncode((imbyte)lIndex, 0, 0);
  }

  for (lIndex = 0, lSubIndex = 0; lSubIndex < 85; lSubIndex++, lIndex += 3)
  {
    /* From (255, 0, 0) to (255, 252, 0)*/
    /* From      Red    to     ~Yellow */
    *(ct++) = imColorEncode(255, (imbyte)lIndex, 0);
  }

  for (lIndex = 0, lSubIndex = 0; lSubIndex < 86; lSubIndex++, lIndex += 3)
  {
    /* From (255, 255, 0) to (255, 255, 255)*/
    /* From     Yellow    to      White  */
    *(ct++) = imColorEncode(255, 255, (imbyte)lIndex);
  }

  return palette;
}
示例#4
0
int imFileFormatRAS::ReadPalette()
{
  unsigned char ras_colors[256 * 3];

  /* reads the color palette */
  imBinFileRead(handle, ras_colors, this->palette_count * 3, 1);

  if (imBinFileError(handle))
    return IM_ERR_ACCESS;

  /* convert the color map to the IM format */
  for (int c = 0; c < this->palette_count; c++)
  {
    if (this->map_type == RAS_RAW)
    {
      int i = c * 3;
      this->palette[c] = imColorEncode(ras_colors[i], 
                                       ras_colors[i+1], 
                                       ras_colors[i+2]);
    }
    else
    {
      this->palette[c] = imColorEncode(ras_colors[c], 
                                       ras_colors[c+this->palette_count], 
                                       ras_colors[c+2*this->palette_count]);
    }
  }

  return IM_ERR_NONE;
}
示例#5
0
文件: im_file.cpp 项目: LuaDist/im
int imFileWriteImageInfo(imFile* ifile, int width, int height, int user_color_mode, int user_data_type)
{
  assert(ifile);
  assert(ifile->is_new);
  imFileFormatBase* ifileformat = (imFileFormatBase*)ifile;

  if (!imImageCheckFormat(user_color_mode, user_data_type))
    return IM_ERR_DATA;

  int error = ifileformat->iformat->CanWrite(ifile->compression, user_color_mode, user_data_type);
  if (error) return error;

  ifile->width = width;
  ifile->height = height;
  ifile->user_color_mode = user_color_mode;
  ifile->user_data_type = user_data_type;

  if (imColorModeSpace(user_color_mode) == IM_BINARY)
  {
    ifile->palette_count = 2;
    ifile->palette[0] = imColorEncode(0, 0, 0);
    ifile->palette[1] = imColorEncode(255, 255, 255);
  }

  return ifileformat->WriteImageInfo();
}
示例#6
0
long* imPaletteUniform(void)
{
  long* palette = imPaletteNew(256);
  long* ct = palette;

  for (int lRedIndex = 0; lRedIndex < 6; lRedIndex++)
    for (int lGreenIndex = 0; lGreenIndex < 6; lGreenIndex++)
      for (int lBlueIndex = 0; lBlueIndex < 6; lBlueIndex++)
      {
        imbyte red = (imbyte)iSixStepsTable[lRedIndex];
        imbyte green = (imbyte)iSixStepsTable[lGreenIndex];
        imbyte blue = (imbyte)iSixStepsTable[lBlueIndex];

        *(ct++) = imColorEncode(red, green, blue);
      }

  /* We initialized only 216 colors (6x6x6), rest 40 colors.*/
  /* Fill them with a gray scale palette.*/
  for (int lIndex = 6; lIndex < 246; lIndex += 6)
  {
    *(ct++) = imColorEncode((imbyte)lIndex, (imbyte)lIndex, (imbyte)lIndex);
  }

  return palette;
}
示例#7
0
文件: im_file.cpp 项目: LuaDist/im
int imFileReadImageInfo(imFile* ifile, int index, int *width, int *height, int *file_color_mode, int *file_data_type)
{
  assert(ifile);
  assert(!ifile->is_new);
  imFileFormatBase* ifileformat = (imFileFormatBase*)ifile;

  if (index >= ifile->image_count)
    return IM_ERR_DATA;

  if (ifile->image_index != -1 &&
      ifile->image_index == index)
  {
    if(width) *width = ifile->width;
    if(height) *height = ifile->height;
    if(file_color_mode) *file_color_mode = ifile->file_color_mode;
    if(file_data_type) *file_data_type = ifile->file_data_type;

    return IM_ERR_NONE;
  }

  ifile->convert_bpp = 0;
  ifile->switch_type = 0;

  int error = ifileformat->ReadImageInfo(index);
  if (error) return error;

  if (!imImageCheckFormat(ifile->file_color_mode, ifile->file_data_type))
    return IM_ERR_DATA;

  if (imColorModeSpace(ifile->file_color_mode) == IM_BINARY)
  {
    ifile->palette_count = 2;
    ifile->palette[0] = imColorEncode(0, 0, 0);
    ifile->palette[1] = imColorEncode(255, 255, 255);
  }

  if (imColorModeSpace(ifile->file_color_mode) == IM_MAP)
  {    
    if (iFileCheckPaletteGray(ifile))
      ifile->file_color_mode = (ifile->file_color_mode & 0xFF00) | IM_GRAY;

    if (iFileCheckPaletteBinary(ifile))
      ifile->file_color_mode = (ifile->file_color_mode & 0xFF00) | IM_BINARY;
  }

  if(width) *width = ifile->width;
  if(height) *height = ifile->height;
  if(file_color_mode) *file_color_mode = ifile->file_color_mode;
  if(file_data_type) *file_data_type = ifile->file_data_type;

  ifile->image_index = index; 

  return IM_ERR_NONE;
}
示例#8
0
long* imPaletteRainbow(void)
{
  long* palette = imPaletteNew(256);
  long* ct = palette;
  int hue;
  unsigned char r, g, b;
  float h, s, i, factor, H;

  s = 1.0f;
  factor = 360.0f / 256.0f;

  for (hue = 0; hue < 256; hue++)
  {
    h = hue * factor;
    h = 300-h;
    if (h < 0) h += 360;
    H = h/57.2957795131f;

    i = imColorHSI_ImaxS(H, cos(H), sin(H));

    imColorHSI2RGBbyte(h, s, i, &r, &g, &b);

    *(ct++) = imColorEncode(r, g, b);;
  }

  return palette;
}
示例#9
0
/***************************************************************************\
* Creates a color as a light userdata. The color value is                   *
* placed in the (void *) value. Not beautiful, but works best.              *
* im.ColorEncode(r, g, b: number) -> (c: color)                             *
\***************************************************************************/
static int imlua_colorencode(lua_State *L)
{
  int red_f, green_f, blue_f;
  unsigned char red_i, green_i, blue_i;
  long color_i;

  red_f   = luaL_checkinteger(L, 1);
  green_f = luaL_checkinteger(L, 2);
  blue_f  = luaL_checkinteger(L, 3);

  if (red_f < 0 || red_f > 255)
    luaL_argerror(L, 1, "color components values should be in range [0, 255]");
  if (green_f < 0 || green_f > 255)
    luaL_argerror(L, 2, "color components values should be in range [0, 255]");
  if (blue_f < 0 ||  blue_f > 255)
    luaL_argerror(L, 3, "color components values should be in range [0, 255]");
  
  red_i   = (unsigned char) (red_f);
  green_i = (unsigned char) (green_f);
  blue_i  = (unsigned char) (blue_f);

  color_i = imColorEncode(red_i, green_i, blue_i);
  lua_pushlightuserdata(L, (void *)color_i);
  
  return 1;
}
示例#10
0
文件: im_file.cpp 项目: LuaDist/im
void imFileClear(imFile* ifile)
{
  // can not reset compression and image_count

  ifile->is_new = 0;
  ifile->attrib_table = 0;

  ifile->line_buffer = 0;
  ifile->line_buffer_size = 0;
  ifile->line_buffer_extra = 0;
  ifile->line_buffer_alloc = 0;

  ifile->convert_bpp = 0;
  ifile->switch_type = 0;

  ifile->width = 0; 
  ifile->height = 0; 
  ifile->image_index = -1; 
  ifile->user_data_type = 0;
  ifile->user_color_mode = 0; 
  ifile->file_data_type = 0;
  ifile->file_color_mode = 0;

  ifile->palette_count = 256;
  for (int i = 0; i < 256; i++)
    ifile->palette[i] = imColorEncode((imbyte)i, (imbyte)i, (imbyte)i);
}
示例#11
0
void imProcessQuantizeRGBUniform(const imImage* src_image, imImage* dst_image, int dither)
{
  imbyte *dst_map=(imbyte*)dst_image->data[0], 
         *red_map=(imbyte*)src_image->data[0],
         *green_map=(imbyte*)src_image->data[1],
         *blue_map=(imbyte*)src_image->data[2];

  imImageSetPalette(dst_image, imPaletteUniform(), 256);

  for (int y = 0; y < src_image->height; y++)
  {
    for (int x = 0; x < src_image->width; x++)
    {
      if (dither)
        *dst_map++ = (imbyte)imPaletteUniformIndexHalftoned(imColorEncode(*red_map++, *green_map++, *blue_map++), x, y);
      else
        *dst_map++ = (imbyte)imPaletteUniformIndex(imColorEncode(*red_map++, *green_map++, *blue_map++));
    }
  }
}
示例#12
0
void imFileFormatAVI::ReadPalette(unsigned char* bmp_colors)
{
  /* convert the color map to the IM format */
  for (int c = 0; c < this->palette_count; c++)
  {
    int i = c * 4;
    this->palette[c] = imColorEncode(bmp_colors[i + 2], 
                                     bmp_colors[i + 1], 
                                     bmp_colors[i]);
  }
}
示例#13
0
long* imPaletteGray(void)
{
  long* palette = (long*)malloc(sizeof(long)*256);
  long* ct = palette;

  for (int lIndex = 0; lIndex < 256; lIndex++)
  {
    /* From (0, 0, 0) to (255, 255, 255)*/
    /* From   Black   to      White     */
    *(ct++) = imColorEncode((imbyte)lIndex, (imbyte)lIndex, (imbyte)lIndex);
  }

  return palette;
}
示例#14
0
long* imPaletteBlueIce(void)
{
  long* palette = imPaletteNew(256);
  long* ct = palette;
  
  for (int lIndex = 0; lIndex < 256; lIndex++)
  {
    /* From (0, 0, 255) to (255, 255, 255)*/
    /* From    Blue    to       White     */
    *(ct++) = imColorEncode((imbyte)lIndex, (imbyte)lIndex, 255);
  }

  return palette;
}
示例#15
0
long* imPaletteYellow(void)
{
  long* palette = imPaletteNew(256);
  long* ct = palette;
  
  for (int lIndex = 0; lIndex < 256; lIndex++)
  {
    /* From (0, 0, 0) to (255, 255, 0)*/
    /* From   Black   to      Yellow  */
    *(ct++) = imColorEncode((imbyte)lIndex, (imbyte)lIndex, 0);
  }

  return palette;
}
示例#16
0
long* imPaletteCian(void)
{
  long* palette = imPaletteNew(256);
  long* ct = palette;
  
  for (int lIndex = 0; lIndex < 256; lIndex++)
  {
    /* From (0, 0, 0) to (0, 255, 255)*/
    /* From   Black   to     Cian    */
    *(ct++) = imColorEncode(0, (imbyte)lIndex, (imbyte)lIndex);
  }

  return palette;
}
示例#17
0
static void ReplaceColor(imImage* image)
{
  int i;
  imbyte* map = (imbyte*)image->data[0];  // gray or red plane

  if (image->color_space == IM_GRAY)
  {
    image->color_space = IM_MAP;
    image->palette[254] = imColorEncode(255, 0, 0);
  }

  for (i = 0; i < image->count; i++)
  {
    if (map[i] == 254)
      map[i] = 255;
  }
}
示例#18
0
int imFileFormatLED::ReadPalette()
{
  int c, r, g, b, i;

  /* convert the color map to the IM format */
  for (c = 0; c < this->palette_count; c++)
  {
    imBinFileReadInteger(handle, &i);
    imBinFileReadInteger(handle, &r);
    imBinFileReadInteger(handle, &g);
    imBinFileReadInteger(handle, &b);

    this->palette[i] = imColorEncode((unsigned char)r, (unsigned char)g, (unsigned char)b);

    if (imBinFileError(handle))
      return IM_ERR_ACCESS;
  }

  return IM_ERR_NONE;
}
示例#19
0
文件: im_file.cpp 项目: LuaDist/im
static void iFileCheckConvertGray(imFile* ifile, imbyte* data)
{
  int i, do_remap = 0;
  imbyte remap[256], r, g, b;

  // enforce the palette to only have grays in the correct order.

  for (i = 0; i < ifile->palette_count; i++)
  {
    imColorDecode(&r, &g, &b, ifile->palette[i]);

    if (r != i)
    {
      ifile->palette[i] = imColorEncode((imbyte)i, (imbyte)i, (imbyte)i);
      do_remap = 1;
    }

    remap[i] = r;
  }

  if (!do_remap)
    return;

  int count = ifile->width*ifile->height;
  for(i = 0; i < count; i++)
  {
    *data = remap[*data];
    data++;
  }

  int transp_count;
  imbyte* transp_map = (imbyte*)imFileGetAttribute(ifile, "TransparencyMap", NULL, &transp_count);
  if (transp_map)
  {
    imbyte new_transp_map[256];
    for (i=0; i<transp_count; i++)
      new_transp_map[i] = transp_map[remap[i]];
    imFileSetAttribute(ifile, "TransparencyMap", IM_BYTE, transp_count, new_transp_map);
  }
}
示例#20
0
int imFileFormatSGI::ReadImageInfo(int index)
{
  (void)index;
  unsigned short word_value, dimension, depth;

  /* reads the number of bits per channel */
  imBinFileRead(handle, &this->bpc, 1, 1);

  /* reads the number of dimensions */
  imBinFileRead(handle, &dimension, 1, 2);

  /* reads the image width */
  imBinFileRead(handle, &word_value, 1, 2);
  this->width = word_value;

  /* reads the image height */
  imBinFileRead(handle, &word_value, 1, 2);
  this->height = word_value;

  /* reads the number of channels */
  imBinFileRead(handle, &depth, 1, 2);

  /* jump 12 bytes (min, max, dummy) */
  imBinFileSeekOffset(handle, 12);

  /* reads the image name */
  char image_name[80];
  imBinFileRead(handle, image_name, 80, 1);

  if (image_name[0] != 0)
    AttribTable()->Set("Description", IM_BYTE, imStrNLen(image_name, 80)+1, image_name);

  /* reads the color map information */
  unsigned int color_map_id; 
  imBinFileRead(handle, &color_map_id, 1, 4);

  if (imBinFileError(handle))
    return IM_ERR_ACCESS;

  this->file_data_type = IM_BYTE;
  if (this->bpc == 2)
    this->file_data_type = IM_USHORT;

  switch (dimension)
  {
  case 1:
    this->height = 1;
    depth = 1;
  case 2:
    depth = 1;
    break;
  case 3:
    break;
  default:
    return IM_ERR_DATA;
  }

  switch (color_map_id)
  {
  case SGI_NORMAL:
    switch(depth)
    {
    case 1:
      this->file_color_mode = IM_GRAY;
      break;
    case 3:
      this->file_color_mode = IM_RGB;
      break;
    case 4:
      this->file_color_mode = IM_RGB | IM_ALPHA;
      break;
    default:
      return IM_ERR_DATA;
    }
    break;
  case SGI_DITHERED:
    this->file_color_mode = IM_MAP;
    break;
  case SGI_COLORMAP:
    this->file_color_mode = IM_RGB;
    break;
  case SGI_SCREEN:
    this->file_color_mode = IM_GRAY;
    break;
  default:
    return IM_ERR_DATA;
  }

  /* jump 404 bytes (dummy) */
  imBinFileSeekOffset(handle, 404);

  if (this->comp_type == SGI_RLE)
  {
    int tablen = this->height * depth;
    this->starttab = (unsigned int *)malloc(tablen * sizeof(int));
    this->lengthtab = (unsigned int *)malloc(tablen * sizeof(int));

    /* reads the compression control information */
    imBinFileRead(handle, this->starttab, tablen, 4);
    imBinFileRead(handle, this->lengthtab, tablen, 4);

    // allocates more than enough since compression algoritm can be ineficient
    this->line_buffer_extra = 2*imImageLineSize(this->width, this->file_color_mode, this->file_data_type);
  }

  if (imBinFileError(handle))
    return IM_ERR_ACCESS;

  if (color_map_id == SGI_DITHERED)
  {
    static int red[8] = {0, 36, 73, 109, 146, 182, 218, 255};
    static int green[8] = {0, 36, 73, 109, 146, 182, 218, 255};
    static int blue[4] = {0, 85, 170, 255};

    int c = 0;
    for (int b = 0; b < 4; b++)
    {
      for (int g = 0; g < 8; g++)
      {
        for (int r = 0; r < 8; r++)
        {
          this->palette[c] = imColorEncode((imbyte)red[r], 
                                           (imbyte)green[g], 
                                           (imbyte)blue[b]);
          c++;
        }
      }
    }
  }

  return IM_ERR_NONE;
}
示例#21
0
long* imPaletteHighContrast(void)
{
  long* palette = imPaletteNew(256);
  long* ct = palette;
  int lIndex;
#define NUM_HC 128

  static struct{ unsigned char r, g, b; } HighContrastColors[NUM_HC] = {
    { 0,0,0 },     

    { 255,0,0 },      { 128,0,0 },      { 64,0,0 },       { 192,0,0 },
    { 0,255,0 },      { 0,128,0 },      { 0,64,0 },       { 0,192,0 },    
    { 0,0,255 },      { 0,0,128 },      { 0,0,64 },       { 0,0,192 },    
    { 255,255,0 },    { 128,128,0 },    { 64,64,0 },      { 192,192,0 },    
    { 255,0,255 },    { 128,0,128 },    { 64,0,64 },      { 192,0,192 },    
    { 0,255,255 },    { 0,128,128 },    { 0,64,64 },      { 0,192,192 },    
    { 255,255,255 },  { 128,128,128 },  { 64,64,64 },     { 192,192,192 },    

    { 255,128,128 },  { 64,255,255 },   { 192,255,255 },   
    { 128,255,128 },  { 255,64,255 },   { 255,192,255 },     
    { 128,128,255 },  { 255,255,64 },   { 255,255,192 },     
    { 255,255,128 },  { 64,64,255 },    { 192,192,255 },     
    { 255,128,255 },  { 64,255,64 },    { 192,255,192 },     
    { 128,255,255 },  { 255,64,64 },    { 255,192,192 },   

    { 128,64,64 },    { 128,192,192 },   
    { 64,128,64 },    { 192,128,192 },   
    { 64,64,128 },    { 192,192,128 },   
    { 128,128,64 },   { 128,128,192 },   
    { 128,64,128 },   { 128,192,128 },   
    { 64,128,128 },   { 192,128,128 },   
    
   { 160,0,0 },      { 32,0,0 },       { 224,0,0 },       { 96,0,0 },    
   { 0,160,0 },      { 0,32,0 },       { 0,224,0 },       { 0,96,0 },    
   { 0,0,160 },      { 0,0,32 },       { 0,0,224 },       { 0,0,96 },    
   { 160,160,0 },    { 32,32,0 },      { 224,224,0 },     { 96,96,0 },   
   { 160,0,160 },    { 32,0,32 },      { 224,0,224 },     { 96,0,96 },   
   { 0,160,160 },    { 0,32,32 },      { 0,224,224 },     { 0,96,96 },   
   { 160,160,160 },  { 32,32,32 },     { 224,224,224 },   { 96,96,96 },  

    { 255,160,160 },  { 32,255,255 },   { 224,255,255 },     { 96,255,255 },  
    { 160,255,160 },  { 255,32,255 },   { 255,224,255 },     { 255,96,255 },   
    { 160,160,255 },  { 255,255,32 },   { 255,255,224 },     { 255,255,96 },   
    { 255,255,160 },  { 32,32,255 },    { 224,224,255 },     { 96,96,255 },   
    { 255,160,255 },  { 32,255,32 },    { 224,255,224 },     { 96,255,96 },   
    { 160,255,255 },  { 255,32,32 },    { 255,224,224 },     { 255,96,96 },  

    { 128,32,32 },    { 64,192,192 },      { 64,224,224 },
    { 32,128,32 },    { 192,64,192 },      { 224,64,224 },
    { 32,32,128 },    { 192,192,64 },      { 224,224,64 },
    { 128,128,32 },   { 64,64,192 },       { 64,64,224 }, 
    { 128,32,128 },   { 64,192,64 },       { 64,224,64 }, 
    { 32,128,128 },   { 192,64,64 },       

 };

  for (lIndex = 0; lIndex < NUM_HC; lIndex++)
  {
    *(ct++) = imColorEncode(HighContrastColors[lIndex].r, 
                            HighContrastColors[lIndex].g, 
                            HighContrastColors[lIndex].b);
  }

  for (; lIndex < 256; lIndex++)
  {
    *(ct++) = imColorEncode(HighContrastColors[lIndex - NUM_HC].r,
                            HighContrastColors[lIndex - NUM_HC].g, 
                            HighContrastColors[lIndex - NUM_HC].b);
  }

  return palette;
}
示例#22
0
long imEncodeColor(unsigned char Red, unsigned char Green, unsigned char Blue)
{
  return imColorEncode(Red, Green, Blue);
}
示例#23
0
long* imPaletteHues(void)
{
  long* palette = imPaletteNew(256);
  long* ct = palette;
  int i;
  float tone, step1 = 255.0f/41.0f, step2 = 255.0f/42.0f;

  /* 1+42+1+41+1+42+1+41+1+42+1+41+1 = 256 */

  /* red */
  *(ct++) = imColorEncode((imbyte)255, 0, 0);

  for (tone = step2, i = 0; i < 42; i++, tone += step2)
  {
    /* From (255, 0, 0) to (255, 255, 0) */
    /* From      Red    to      Yellow   */
    *(ct++) = imColorEncode((imbyte)255, (imbyte)tone, 0);
  }

  /* yellow */
  *(ct++) = imColorEncode((imbyte)255, (imbyte)255, 0);

  for (tone = step1, i = 0; i < 41; i++, tone += step1)
  {
    /* From (255, 255, 0) to (0, 255, 0)  */
    /* From     Yellow    to    Green    */
    *(ct++) = imColorEncode((imbyte)(255.0f-tone), (imbyte)255, 0);
  }

  /* green */
  *(ct++) = imColorEncode(0, (imbyte)255, 0);;

  for (tone = step2, i = 0; i < 42; i++, tone += step2)
  {
    /* From (0, 255, 0) to (0, 255, 255) */
    /* From    Green    to     Cian      */
    *(ct++) = imColorEncode(0, (imbyte)255, (imbyte)tone);
  }

  /* cian */
  *(ct++) = imColorEncode(0, (imbyte)255, (imbyte)255);

  for (tone = step1, i = 0; i < 41; i++, tone += step1)
  {
    /* From (0, 255, 255) to (0, 0, 255) */
    /* From     Cian      to     Blue    */
    *(ct++) = imColorEncode(0, (imbyte)(255.0f-tone), (imbyte)255);
  }

  /* blue */
  *(ct++) = imColorEncode(0, 0, (imbyte)255);

  for (tone = step2, i = 0; i < 42; i++, tone += step2)
  {
    /* From (0, 0, 255) to (255, 0, 255) */
    /* From    Blue     to    Magenta    */
    *(ct++) = imColorEncode((imbyte)tone, 0, (imbyte)255);
  }

  /* magenta */
  *(ct++) = imColorEncode((imbyte)255, 0, (imbyte)255);

  for (tone = step1, i = 0; i < 41; i++, tone += step1)
  {
    /* From (255, 0, 255) to (255, 0, 0) */
    /* From    Magenta    to      Red    */
    *(ct++) = imColorEncode((imbyte)255, 0, (imbyte)(255.0f-tone));
  }

  /* black */
  *(ct++) = imColorEncode(0, 0, 0);;

  return palette;
}