Beispiel #1
0
int imFileFormatPFM::ReadImageInfo(int index)
{
  (void)index;

  if (this->image_type == 'f')
    this->file_color_mode = IM_GRAY;
  else
    this->file_color_mode = IM_RGB | IM_PACKED;

  if (!imBinFileReadInteger(handle, &this->width))
    return IM_ERR_ACCESS;

  if (!imBinFileReadInteger(handle, &this->height))
    return IM_ERR_ACCESS;

  if (this->height <= 0 || this->width <= 0)
    return IM_ERR_DATA;

  double byte_order = 1.0;
  if (!imBinFileReadReal(handle, &byte_order))
    return IM_ERR_ACCESS;

  if (byte_order > 0)
    imBinFileByteOrder(handle, IM_BIGENDIAN);
  else
    imBinFileByteOrder(handle, IM_LITTLEENDIAN);

  this->file_data_type = IM_FLOAT;

  return IM_ERR_NONE;
}
Beispiel #2
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;
}
Beispiel #3
0
int imFileFormatLED::ReadImageInfo(int index)
{
  (void)index;

  this->palette_count = this->pal_count;

  if (ReadPalette() != IM_ERR_NONE)
    return IM_ERR_ACCESS;

  imBinFileReadInteger(handle, &this->width);
  imBinFileReadInteger(handle, &this->height);
 
  if (imBinFileError(handle))
    return IM_ERR_ACCESS;

  this->file_data_type = IM_BYTE;
  this->file_color_mode = IM_MAP;
  this->file_color_mode |= IM_TOPDOWN;

  return IM_ERR_NONE;
}
Beispiel #4
0
int imFileFormatLED::ReadImageData(void* data)
{
  int value;

  imCounterTotal(this->counter, this->height, "Reading LED...");

  for (int row = 0; row < this->height; row++)
  {
    for (int col = 0; col < this->width; col++)
    {
      if (!imBinFileReadInteger(handle, &value))
        return IM_ERR_ACCESS;

      ((imbyte*)this->line_buffer)[col] = (unsigned char)value;
    }

    imFileLineBufferRead(this, data, row, 0);

    if (!imCounterInc(this->counter))
      return IM_ERR_COUNTER;
  } 

  return IM_ERR_NONE;
}
Beispiel #5
0
int imFileFormatRAW::ReadImageData(void* data)
{
  int count = imFileLineBufferCount(this);
  int line_count = imImageLineCount(this->width, this->file_color_mode);
  int type_size = iFileDataTypeSize(this->file_data_type, this->switch_type);

  // treat complex as 2 real
  if (this->file_data_type == IM_CFLOAT) 
  {
    type_size /= 2;
    line_count *= 2;
  }

  int ascii;
  if (imStrEqual(this->compression, "ASCII"))
    ascii = 1;
  else
    ascii = 0;

  imCounterTotal(this->counter, count, "Reading RAW...");

  int row = 0, plane = 0;
  for (int i = 0; i < count; i++)
  {
    if (ascii)
    {
      for (int col = 0; col < line_count; col++)
      {
        if (this->file_data_type == IM_FLOAT)
        {
          float value;
          if (!imBinFileReadFloat(handle, &value))
            return IM_ERR_ACCESS;

          ((float*)this->line_buffer)[col] = value;
        }
        else
        {
          int value;
          if (!imBinFileReadInteger(handle, &value))
            return IM_ERR_ACCESS;

          if (this->file_data_type == IM_INT)
            ((int*)this->line_buffer)[col] = value;
          else if (this->file_data_type == IM_SHORT)
            ((short*)this->line_buffer)[col] = (short)value;
          else if (this->file_data_type == IM_USHORT)
            ((imushort*)this->line_buffer)[col] = (imushort)value;
          else
            ((imbyte*)this->line_buffer)[col] = (unsigned char)value;
        }
      }
    }
    else
    {
      imBinFileRead(this->handle, (imbyte*)this->line_buffer, line_count, type_size);

      if (imBinFileError(this->handle))
        return IM_ERR_ACCESS;
    }

    imFileLineBufferRead(this, data, row, plane);

    if (!imCounterInc(this->counter))
      return IM_ERR_COUNTER;

    imFileLineBufferInc(this, &row, &plane);

    if (this->padding)
      imBinFileSeekOffset(this->handle, this->padding);
  }

  return IM_ERR_NONE;
}