summaryrefslogtreecommitdiff
path: root/im/src/im_fileraw.cpp
blob: 91be82603207e9c45a7fc97cbd5c728c543e2b4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/** \file
 * \brief RAW File Format Open/New Functions
 *
 * See Copyright Notice in im_lib.h
 * $Id: im_fileraw.cpp,v 1.3 2009/09/10 17:33:35 scuri Exp $
 */

#include "im.h"
#include "im_image.h"
#include "im_util.h"
#include "im_counter.h"
#include "im_raw.h"
#include "im_format.h"
#include "im_format_raw.h"

#include <stdlib.h>
#include <assert.h>


imFile* imFileOpenRaw(const char* file_name, int *error)
{
  assert(file_name);

  imFormat* iformat = imFormatInitRAW();
  imFileFormatBase* ifileformat = iformat->Create();
  *error = ifileformat->Open(file_name);
  if (*error)
  {
    delete ifileformat;
    return NULL;
  }

  imFileClear(ifileformat);

  ifileformat->attrib_table = new imAttribTable(599);

  ifileformat->counter = imCounterBegin(file_name);

  return ifileformat;
}

imFile* imFileNewRaw(const char* file_name, int *error)
{
  assert(file_name);

  imFormat* iformat = imFormatInitRAW();
  imFileFormatBase* ifileformat = iformat->Create();
  *error = ifileformat->New(file_name);
  if (*error) 
  {
    delete ifileformat;
    return NULL;
  }
   
  imFileClear(ifileformat);

  ifileformat->is_new = 1;
  ifileformat->image_count = 0;
  ifileformat->compression[0] = 0;

  ifileformat->attrib_table = new imAttribTable(101);

  ifileformat->counter = imCounterBegin(file_name);

  return ifileformat;
}