24 |
#include <errno.h> |
#include <errno.h> |
25 |
#include <stdio.h> |
#include <stdio.h> |
26 |
|
|
|
#include <AppKit/NSBitmapImageRep.h> |
|
27 |
#include <Foundation/NSArray.h> |
#include <Foundation/NSArray.h> |
28 |
#include <Foundation/NSException.h> |
#include <Foundation/NSException.h> |
29 |
|
#include <Foundation/NSDebug.h> |
30 |
|
#include <AppKit/NSBitmapImageRep.h> |
31 |
|
|
32 |
#include "Map/MapTerrain.h" |
#include "Map/MapTerrain.h" |
33 |
|
|
72 |
{ |
{ |
73 |
NSArray *imageReps = [NSBitmapImageRep imageRepsWithFile: imageName]; |
NSArray *imageReps = [NSBitmapImageRep imageRepsWithFile: imageName]; |
74 |
if ([imageReps count] != 1) |
if ([imageReps count] != 1) |
75 |
return nil; |
{ |
76 |
|
NSWarnMLog (@"Could not open map file"); |
77 |
|
return nil; |
78 |
|
} |
79 |
|
|
80 |
NSBitmapImageRep *image = [imageReps objectAtIndex: 0]; |
NSBitmapImageRep *image = [imageReps objectAtIndex: 0]; |
81 |
|
|
82 |
if ( [image bitsPerSample] != 8 |
if ( [image bitsPerSample] != 8 |
83 |
|| [image samplesPerPixel] != 1 ) // gray level check |
|| [image samplesPerPixel] != 1 ) // gray level check |
84 |
return nil; |
{ |
85 |
|
NSWarnMLog (@"Incorrect map colors file format"); |
86 |
|
return nil; |
87 |
|
} |
88 |
|
|
89 |
/* FIXME - Must be retained */ |
/* FIXME - Must be retained */ |
90 |
_heightField = [image bitmapData]; |
_heightField = [image bitmapData]; |