Ejemplo n.º 1
0
void imFileFormatJPEG::iWriteExifAttrib(imAttribTable* attrib_table)
{
  ExifData* exif = exif_data_new();

  ExifByteOrder byte_order;
  if (imBinCPUByteOrder() == IM_LITTLEENDIAN)
    byte_order = EXIF_BYTE_ORDER_INTEL;
  else
    byte_order = EXIF_BYTE_ORDER_MOTOROLA;
    
  exif_data_set_byte_order(exif, byte_order);

  attrib_table->ForEach(exif, (imAttribTableCallback)iExifWriteTag);

  imbyte* data = NULL;
  unsigned int data_size = 0;

  exif_data_save_data(exif, &data, &data_size);

  if (data)
  {
    jpeg_write_marker(&this->cinfo, JPEG_APP0+1, data, data_size);
    free(data);
  }

  exif_data_free(exif);
}
Ejemplo n.º 2
0
int imFileFormatPFM::WriteImageInfo()
{
  this->file_data_type = this->user_data_type;
  this->file_color_mode = imColorModeSpace(this->user_color_mode);

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

  imBinFilePrintf(handle, "P%c\n", (int)this->image_type);

  if (imBinFileError(handle))
    return IM_ERR_ACCESS;

  imBinFilePrintf(handle, "%d ", this->width);
  imBinFilePrintf(handle, "%d\n", this->height);

  if (imBinCPUByteOrder() == IM_BIGENDIAN)
    imBinFilePrintf(handle, "1.0\n");
  else
    imBinFilePrintf(handle, "-1.0\n");

  /* tests if everything was ok */
  if (imBinFileError(handle))
    return IM_ERR_ACCESS;

  return IM_ERR_NONE;
}
Ejemplo n.º 3
0
void imBinSystemFileHandle::New(const char* pFileName)
{
  // the file was successfully opened already the client 

  HANDLE file_handle = (HANDLE)pFileName;
  this->FileHandle = file_handle;
  SetByteOrder(imBinCPUByteOrder());
  this->IsNew = 1;
  this->Error = 0;
}
Ejemplo n.º 4
0
void imBinSystemFileHandle::New(const char* pFileName)
{
  // the file was successfully opened already the client

  int *s = (int*)pFileName;
  this->FileHandle = s[0];
  SetByteOrder(imBinCPUByteOrder());
  this->IsNew = 1;
  this->Error = 0;
}
Ejemplo n.º 5
0
void imBinSystemFile::New(const char* pFileName)
{
  this->FileHandle = CreateFile(pFileName, GENERIC_READ | GENERIC_WRITE, 
                                           0, 
                                           NULL, 
                                           CREATE_ALWAYS,
                                           FILE_ATTRIBUTE_NORMAL,
                                           NULL);
  this->Error = (this->FileHandle == INVALID_HANDLE_VALUE)? 1: 0;
  SetLastError(NO_ERROR);
  SetByteOrder(imBinCPUByteOrder());
  this->IsNew = 1;
}
Ejemplo n.º 6
0
void imBinSystemFile::Open(const char* pFileName)
{
  this->FileHandle = CreateFile(pFileName, GENERIC_READ, 
                                           FILE_SHARE_READ, 
                                           NULL, 
                                           OPEN_EXISTING,
                                           FILE_ATTRIBUTE_NORMAL,
                                           NULL);
  this->Error = (this->FileHandle == INVALID_HANDLE_VALUE)? 1: 0;
  SetLastError(NO_ERROR);
  SetByteOrder(imBinCPUByteOrder());
  this->IsNew = 0;
}
Ejemplo n.º 7
0
void imBinSystemFile::New(const char* pFileName)
{
  int mode = O_WRONLY | O_CREAT | O_TRUNC;           
#ifdef O_BINARY
    mode |= O_BINARY;
#endif        
  this->FileHandle = open(pFileName, mode, 0666); // User/Group/Other can read and write
  if (this->FileHandle < 0) 
    this->Error = errno;
  else
    this->Error = 0;
  SetByteOrder(imBinCPUByteOrder());
  this->IsNew = 1;
}
Ejemplo n.º 8
0
void imBinSystemFile::Open(const char* pFileName)
{
  int mode = O_RDONLY;
#ifdef O_BINARY
    mode |= O_BINARY;
#endif        
  this->FileHandle = open(pFileName, mode, 0);
  if (this->FileHandle < 0) 
    this->Error = errno;
  else
    this->Error = 0;
  SetByteOrder(imBinCPUByteOrder());
  this->IsNew = 0;
}
Ejemplo n.º 9
0
void imBinMemoryFile::Open(const char* pFileName)
{
    this->file_name = (imBinMemoryFileName*)pFileName;

    SetByteOrder(imBinCPUByteOrder());
    this->IsNew = 0;

    assert(this->file_name->size);

    this->Buffer = this->file_name->buffer;
    this->BufferSize = this->file_name->size;
    this->Reallocate = this->file_name->reallocate;
    this->CurrentSize = this->BufferSize;
    this->CurPos = this->Buffer;
    this->Error = 0;
}
Ejemplo n.º 10
0
void imBinMemoryFile::New(const char* pFileName)
{
    this->file_name = (imBinMemoryFileName*)pFileName;

    SetByteOrder(imBinCPUByteOrder());
    this->IsNew = 1;

    assert(this->file_name->size);

    this->Buffer = this->file_name->buffer;
    this->BufferSize = this->file_name->size;
    this->Reallocate = this->file_name->reallocate;
    this->CurrentSize = 0;

    if (!this->Buffer)
    {
        this->Buffer = (unsigned char*)malloc(this->BufferSize);
        this->file_name->buffer = this->Buffer;
    }

    this->CurPos = this->Buffer;
    this->Error = 0;
}
Ejemplo n.º 11
0
void imBinStreamFile::New(const char* pFileName)
{
    this->FileHandle = fopen(pFileName, "wb");
    SetByteOrder(imBinCPUByteOrder());
    this->IsNew = 1;
}