Esempio n. 1
0
int imFileFormatJPEG::New(const char* file_name)
{
  this->handle = imBinFileNew(file_name);
  if (this->handle == NULL)
    return IM_ERR_OPEN;

  this->cinfo.err = jpeg_std_error(&this->jerr.pub);
  this->jerr.pub.error_exit = JPEGerror_exit;
  this->jerr.pub.output_message = JPEGoutput_message;
  this->jerr.pub.emit_message = JPEGemit_message;
  
  /* Establish the setjmp return context for error_exit to use. */
  if (setjmp(this->jerr.setjmp_buffer)) 
  {
    /* If we get here, the JPEG code has signaled an error.
     * We need to clean up the JPEG object, close the input file, and return. */
    jpeg_destroy_compress(&this->cinfo);
    imBinFileClose(this->handle);
    return IM_ERR_ACCESS;
  }
  
  jpeg_create_compress(&this->cinfo);

  /* Step 2: specify data destination (eg, a file) */
  jpeg_stdio_dest(&this->cinfo, (FILE*)this->handle);

  strcpy(this->compression, "JPEG");
  this->image_count = 1;

  return IM_ERR_NONE;
}
Esempio n. 2
0
jas_stream_t *jas_binfile_open(const char *file_name, int is_new)
{
  void* handle;
  jas_stream_t *stream;

  if (is_new)
    handle = (void*)imBinFileNew(file_name);
  else
    handle = (void*)imBinFileOpen(file_name);

  if (!handle)
    return 0;

  /* Allocate a stream object. */
  stream = jas_stream_create();

  if (is_new)
    stream->openmode_ = JAS_STREAM_WRITE | JAS_STREAM_CREATE | JAS_STREAM_BINARY;
  else
    stream->openmode_ = JAS_STREAM_READ | JAS_STREAM_BINARY;

  /* Select the operations for a file stream object. */
  stream->ops_ = &jas_stream_fileops;

  stream->obj_ = handle;

  /* By default, use full buffering for this type of stream. */
  jas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);

  return stream;
}
Esempio n. 3
0
int imFileFormatRAW::New(const char* file_name)
{
  this->handle = imBinFileNew(file_name);
  if (this->handle == NULL)
    return IM_ERR_OPEN;

  this->padding = 0;

  return IM_ERR_NONE;
}
Esempio n. 4
0
int imFileFormatPFM::New(const char* file_name)
{
  /* opens the binary file for writing */
  handle = imBinFileNew(file_name);
  if (!handle)
    return IM_ERR_OPEN;

  this->image_count = 1;  

  return IM_ERR_NONE;
}
Esempio n. 5
0
int imFileFormatBMP::New(const char* file_name)
{
  /* opens the binary file for writing with intel byte order */
  handle = imBinFileNew(file_name);
  if (!handle)
    return IM_ERR_OPEN;

  imBinFileByteOrder(handle, IM_LITTLEENDIAN); 

  this->image_count = 1;

  return IM_ERR_NONE;
}
Esempio n. 6
0
int imFileFormatSGI::New(const char* file_name)
{
  /* opens the binary file for writing with motorola byte order */
  handle = imBinFileNew(file_name);
  if (!handle)
    return IM_ERR_OPEN;

  imBinFileByteOrder(handle, IM_BIGENDIAN); 

  this->starttab = NULL;
  this->lengthtab = NULL;

  this->image_count = 1;

  return IM_ERR_NONE;
}
Esempio n. 7
0
int imFileFormatLED::New(const char* file_name)
{
  /* opens the binary file for writing */
  handle = imBinFileNew(file_name);
  if (!handle)
    return IM_ERR_OPEN;

  imBinFileWrite(handle, (void*)"LEDImage = IMAGE", 16, 1);

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

  return IM_ERR_NONE;
}