Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Instance Methods | Protected Attributes
RLE Class Reference

#import "RLE.h"

Inheritance diagram for RLE:
[legend]
Collaboration diagram for RLE:
[legend]

Instance Methods

(id) - init
 
(id) - open:
 
() - strncpy [implementation]
 
() - return(self) [implementation]
 
- Instance Methods inherited from Image
(id) - displayImage
 
(id) - drawSelf::
 
(id) - free
 
(id) - saveAsTiff:usingCompression:
 
(id) - saveAsEPS:
 
(id) - windowWillClose:
 

Protected Attributes

struct rle_hdr rle_file_hdr
 
- Protected Attributes inherited from Image
id thiswindow
 
id thisview
 
id tiffimage
 
int xsize
 
int ysize
 
void * rmap
 
void * gmap
 
void * bmap
 
void * amap
 
unsigned char * r
 
unsigned char * g
 
unsigned char * b
 
unsigned char * a
 
NXZone * newZone
 
char fileName [1024]
 
char windowIconName [1024]
 
int numColors
 
NXRect temprect
 

Detailed Description

Definition at line 13 of file RLE.h.

Method Documentation

- (id) init

Implements Image.

Referenced by Myapp::appOpenFile:type:.

Here is the caller graph for this function:

- (id) open: (char *)  filename

Definition at line 31 of file RLE.m.

References Image::a, rle_hdr::alpha, Image::b, Image::displayImage, Image::fileName, Image::g, rle_hdr::ncolors, Image::numColors, Image::r, rle_hdr::rle_file, rle_file_hdr, rle_get_setup(), rle_getrow(), rle_names(), rle_open_f_noexit(), rle_row_alloc(), rle_row_free(), Image::rmap, Image::thisview, rle_hdr::xmax, rle_hdr::xmin, Image::xsize, rle_hdr::ymax, rle_hdr::ymin, and Image::ysize.

Referenced by Myapp::appOpenFile:type:.

31  :(char *)filename
32 {
33  int i,j,row_pos;
34 
35  rle_pixel **scan;
36 
37  thisview = self;
38  rmap = 0;
39 
40  strncpy(fileName,filename,1024);
41  rle_file_hdr.rle_file = rle_open_f_noexit("RLEViewer", fileName, "rb");
42  rle_names( &rle_file_hdr, "RLEViewer", filename, 0 );
43 
44  if (rle_file_hdr.rle_file == NULL) {
45  NXRunAlertPanel("RLE ERROR", "Can't open %s", NULL, NULL, NULL, fileName);
46  return(self);
47  }
48 
49 
50  //Read in the header from the RLE file
52  NXRunAlertPanel("RLE ERROR", "%s Not an RLE file ", NULL, NULL, NULL, fileName);
53  return(self);
54  }
55 
56  xsize = rle_file_hdr.xmax - rle_file_hdr.xmin + 1;
57  ysize = rle_file_hdr.ymax - rle_file_hdr.ymin + 1;
58 
60  rle_file_hdr.xmin = 0;
62 
63  if (rle_file_hdr.alpha && (numColors == 3))
64  numColors++;
65 
66  if (rle_row_alloc(&rle_file_hdr,&scan) < 0){
67  NXRunAlertPanel("RLE ERROR", "%s Malloc Error ", NULL, NULL, NULL, fileName);
68  return(self);
69  }
70 
71  // Read each scan line into memory ready for displaying.
72  if (numColors == 1){
73  r = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
74  for (i = ysize; i > 0; i--) {
75 
76  rle_getrow(&rle_file_hdr, scan);
77  j = i*xsize;
78  row_pos = 0;
79 
80  while(j <= (i*xsize)+xsize){ // Copy each scanline into a temp
81  r[j]=scan[0][row_pos]; // dataspace
82  j++;
83  row_pos++;
84  }
85  }
86  }
87  if (numColors == 3){
88  r = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
89  g = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
90  b = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
91  for (i = ysize; i > 0; i--) {
92 
93  rle_getrow(&rle_file_hdr, scan);
94  j = i*xsize;
95  row_pos = 0;
96 
97  while(j <= (i*xsize)+xsize){ // Copy each scanline into a temp
98  r[j]=scan[0][row_pos]; // dataspace
99  g[j]=scan[1][row_pos];
100  b[j]=scan[2][row_pos];
101  j++;
102  row_pos++;
103  }
104  }
105  }
106 
107  if (numColors == 4){
108  r = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
109  g = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
110  b = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
111  a = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
112 
113  for (i = ysize; i > 0; i--) {
114 
115  rle_getrow(&rle_file_hdr, scan);
116  j = i*xsize;
117  row_pos = 0;
118 
119  while(j <= (i*xsize)+xsize){ // Copy each scanline into a temp
120  r[j]=scan[0] [row_pos]; // dataspace
121  g[j]=scan[1] [row_pos];
122  b[j]=scan[2] [row_pos];
123  a[j]=scan[-1][row_pos];
124  j++;
125  row_pos++;
126  }
127  }
128  }
129 
130  // Program WILL DIE if you have a file with a valid rle header but
131  // nothing for it to read, it will read the NOTHING in but when you
132  // try to render it, the program will die.
133 
134  rle_row_free(&rle_file_hdr,scan);
135  fclose(rle_file_hdr.rle_file);
136  [self displayImage];
137  return(self);
138 }
FILE * rle_open_f_noexit(const char *prog_name, const char *f_name, const char *mode)
strncpy(windowIconName,"rle.icon.tiff", 14)
void rle_row_free(rle_hdr *the_hdr, rle_pixel **scanp)
Definition: rle_row_alc.c:114
int xmin
Definition: rle.h:100
NXZone * newZone
Definition: Image.h:21
unsigned char * g
Definition: Image.h:20
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
Definition: rle_row_alc.c:56
struct rle_hdr rle_file_hdr
Definition: RLE.h:15
unsigned char * r
Definition: Image.h:20
#define RLE_SUCCESS
Definition: rle.h:70
unsigned char * a
Definition: Image.h:20
unsigned char ** scan
Definition: rle.c:26
char fileName[1024]
Definition: Image.h:22
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
int rle_get_setup(rle_hdr *the_hdr)
Definition: rle_getrow.c:74
int xmax
Definition: rle.h:100
unsigned char * b
Definition: Image.h:20
void * rmap
Definition: Image.h:19
int ymax
Definition: rle.h:100
unsigned char rle_pixel
Definition: rle.h:56
int i
Definition: rletorla.c:82
int alpha
Definition: rle.h:100
int ysize
Definition: Image.h:18
int xsize
Definition: Image.h:18
id thisview
Definition: Image.h:16
int numColors
Definition: Image.h:24
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
FILE * rle_file
Definition: rle.h:114
int ncolors
Definition: rle.h:100

Here is the call graph for this function:

Here is the caller graph for this function:

- (return(self))
implementation

Implements Image.

- strncpy (windowIconName
("rle.icon.tiff") 
(14)   
implementation

Field Documentation

- (struct rle_hdr) rle_file_hdr
protected

Definition at line 15 of file RLE.h.

Referenced by open:.


The documentation for this class was generated from the following files: