home *** CD-ROM | disk | FTP | other *** search
- #import "ToyWinBMP.h"
- #import "bmp.h"
-
- @implementation ToyWinBMP
-
- - (int)drawToyWin:(const char *)fileName Type:(int)type Num:(int)num
- {
- FILE *fp;
- bmpHeader *bh = NULL;
- commonInfo *cinf = NULL;
- int bits = 8, err = 0;
- unsigned char *map[5];
-
- if ((fp = fopen(fileName, "r")) == NULL)
- return Err_OPEN;
- if ((bh = loadBmpHeader(fp, &err)) == NULL) {
- (void)fclose(fp);
- return err;
- }
-
- [self initLocateWindow:fileName Width:bh->x Height:bh->y Num:num];
-
- /* Bitmap data of planes in 'map[]' is one block of memory area.
- map[0] is beginning of the area, and map[1] = map[0] + (size of plane),
- and so on. But, if the image is monochrome, map[1] is NULL.
- The area of map[0] and (commonInfo *)cinf are kept in an object of
- ToyView, and freed by it.
- */
- err = bmpGetImage(fp, bh, &bits, map);
- cinf = bmpInfo(bh, bits, (map[1] == NULL));
- freeBmpHeader(bh);
- (void)fclose(fp);
- if (err) /* •ä„ö⁄˛⁄ë */
- errAlert(fileName, err);
- if ([self drawView:map info: cinf] == nil)
- return -1;
- return 0;
- }
-
- @end
-