home *** CD-ROM | disk | FTP | other *** search
- /*
- #### # # # #
- # # # # # The FreeWare C library for
- # # ## ### # # # # ### RISC OS machines
- # # # # # # # # # # # ___________________________________
- # # #### ### ## # # # #
- # # # # # # # # # # Please refer to the accompanying
- #### ### #### # # ##### # ### documentation for conditions of use
- ________________________________________________________________________
-
- File: Clear.c.Save
- Author: Copyright © 1993 Jason Howat
- Version: 1.00 (16 Dec 1993)
- Purpose: Save a Clear file to disk.
- */
-
-
- #include <string.h>
-
- #include "Desk.Clear.h"
- #include "Desk.File.h"
- #include "Desk.Wimp.h"
-
-
- void Desk_Clear_Save(Desk_clear_picture *picture, char *filename)
- {
- Desk_file_handle out;
- unsigned colours,
- entry;
- unsigned Desk_bitmap_size;
- Desk_palette_entry *palette;
-
-
- if((out = Desk_File_Open(filename, Desk_file_WRITE)) == 0)
- return;
-
- Desk_File_SetType(filename, 0x690);
-
- Desk_File_WriteBytes(out, picture->creator, strlen(picture->creator) + 1);
-
- Desk_File_Write32(out, picture->creatorversion);
- Desk_File_Write32(out, picture->width);
- Desk_File_Write32(out, picture->height);
- Desk_File_Write32(out, picture->bpp);
-
- if(picture->bpp <= 8)
- {
- colours = 1 << picture->bpp;
- palette = picture->palette;
- for(entry = 0 ; entry < colours ; entry++)
- {
- Desk_File_Write8(out, palette[entry].data.red);
- Desk_File_Write8(out, palette[entry].data.green);
- Desk_File_Write8(out, palette[entry].data.blue);
- }
-
- Desk_bitmap_size = picture->width * picture->height;
- }
- else
- Desk_bitmap_size = 3 * picture->width * picture->height;
-
- Desk_File_WriteBytes(out, picture->bitmap, Desk_bitmap_size);
-
- Desk_File_Close(out);
- }
-