Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Instance Methods
RASF Class Reference

#import "RASF.h"

Inheritance diagram for RASF:
[legend]
Collaboration diagram for RASF:
[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:
 

Additional Inherited Members

- 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 RASF.h.

Method Documentation

- (id) init

Implements Image.

- (id) open: (char *)  filename

Definition at line 36 of file RASF.m.

References Image::b, Image::displayImage, Image::fileName, Image::g, Image::numColors, Image::r, Image::rmap, Image::thisview, Image::xsize, and Image::ysize.

36  :(char *)filename
37 {
38  NXStream *fp;
39  int x,y;
40  int i;
41  unsigned char red,green,blue,n;
42  unsigned char buf[80];
43  int count = 0;
44 
45  thisview = self;
46  rmap = 0;
47  strncpy(fileName,filename,1024);
48  if ((fp = NXMapFile(fileName,NX_READONLY)) == NULL) {
49  NXRunAlertPanel("RASF ERROR", "Can't open %s", NULL, NULL, NULL, fileName);
50  return(self);
51  }
52 
53  //Read in the header from the RASF file
54  NXRead(fp,buf,sizeof(char)*8);
55  if(strncmp((char *)buf,"gl RASF",8)){
56  NXRunAlertPanel("RASF ERROR", "%s Not an RASF file ", NULL, NULL, NULL, fileName);
57  return(self);
58  }
59 
60  // Read in the size of the raster file from the header
61  for (i=0;i<2;i++){
62  NXRead(fp,&red,sizeof(char));
63  }
64  NXRead(fp,&red,sizeof(char));
65  NXRead(fp,&green,sizeof(char));
66  xsize=red*256+green;
67 
68  for (i=0;i<2;i++){
69  NXRead(fp,&red,sizeof(char));
70  }
71  NXRead(fp,&red,sizeof(char));
72  NXRead(fp,&green,sizeof(char));
73  ysize=red*256+green;
74 
75  // Now comes the erase values which we will just ignore
76  for (i=0;i<64;i++){
77  NXRead(fp,&red,sizeof(char));
78  }
79 
80  // Allocate three buffers to store the R,G,B Triplets
81  r = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
82  g = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
83  b = (unsigned char *)NXZoneMalloc(newZone,ysize*xsize*(sizeof(unsigned char)));
84 
85  i = 0;
86  for (y=(ysize-1);y>=0;y--){
87  for (x=0;x<xsize;x++){
88  if (count == 0){
89  NXRead(fp,&red,sizeof(char));
90  NXRead(fp,&green,sizeof(char));
91  NXRead(fp,&blue,sizeof(char));
92  NXRead(fp,&n,sizeof(char));
93  r[i] = red;
94  g[i] = green;
95  b[i] = blue;
96  i++;
97  count=n;
98  }else{
99  count--;
100  r[i] = red;
101  g[i] = green;
102  b[i] = blue;
103  i++;
104  }
105  }
106  }
107 
108  numColors = 3;
109  [self displayImage];
110  NXCloseMemory(fp,NX_FREEBUFFER);
111  return(self);
112 }
NXZone * newZone
Definition: Image.h:21
unsigned char * g
Definition: Image.h:20
static unsigned char blue[256]
Definition: rastorle.c:71
unsigned char * r
Definition: Image.h:20
static int y
Definition: getami.c:691
char fileName[1024]
Definition: Image.h:22
static int x
Definition: getami.c:691
static unsigned char green[256]
Definition: rastorle.c:71
static char buf[4096 +1]
Definition: into.c:46
strncpy(windowIconName,"rasf.icon.tiff", 14)
unsigned char * b
Definition: Image.h:20
void * rmap
Definition: Image.h:19
FILE * fp
Definition: pgmtorle.c:49
int i
Definition: rletorla.c:82
int ysize
Definition: Image.h:18
int xsize
Definition: Image.h:18
id thisview
Definition: Image.h:16
static unsigned char red[256]
Definition: rastorle.c:71
int numColors
Definition: Image.h:24

Here is the call graph for this function:

- (return(self))
implementation

Implements Image.

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

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