| 1 |
/* |
| 2 |
* Portions of this file are copyright Rebirth contributors and licensed as |
| 3 |
* described in COPYING.txt. |
| 4 |
* Portions of this file are copyright Parallax Software and licensed |
| 5 |
* according to the Parallax license below. |
| 6 |
* See COPYING.txt for license details. |
| 7 |
|
| 8 |
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
| 9 |
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
| 10 |
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
| 11 |
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
| 12 |
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
| 13 |
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
| 14 |
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
| 15 |
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
| 16 |
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
| 17 |
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* |
| 22 |
* Header for IFF routines |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
#ifndef _IFF_H |
| 27 |
#define _IFF_H |
| 28 |
|
| 29 |
#include <array> |
| 30 |
#include <memory> |
| 31 |
#include "pstypes.h" |
| 32 |
#include "fwd-gr.h" |
| 33 |
|
| 34 |
constexpr std::integral_constant<std::size_t, 30> MAX_BITMAPS_PER_BRUSH{}; |
| 35 |
|
| 36 |
//Error codes for read & write routines |
| 37 |
enum class iff_status_code : unsigned |
| 38 |
{ |
| 39 |
no_error = 0, //everything is fine, have a nice day |
| 40 |
no_mem = 1, //not enough mem for loading or processing |
| 41 |
unknown_form = 2, //IFF file, but not a bitmap |
| 42 |
not_iff = 3, //this isn't even an IFF file |
| 43 |
no_file = 4, //cannot find or open file |
| 44 |
bad_bm_type = 5, //tried to save invalid type, like bm_mode::rgb15 |
| 45 |
corrupt = 6, //bad data in file |
| 46 |
form_anim = 7, //this is an anim, with non-anim load rtn |
| 47 |
form_bitmap = 8, //this is not an anim, with anim load rtn |
| 48 |
too_many_bms = 9, //anim read had more bitmaps than room for |
| 49 |
unknown_mask = 10, //unknown masking type |
| 50 |
read_error = 11, //error reading from file |
| 51 |
bm_mismatch = 12, //bm being loaded doesn't match bm loaded into |
| 52 |
}; |
| 53 |
|
| 54 |
struct iff_read_result |
| 55 |
{ |
| 56 |
iff_status_code status; |
| 57 |
unsigned n_bitmaps{}; |
| 58 |
palette_array_t palette; |
| 59 |
std::array<std::unique_ptr<grs_main_bitmap>, MAX_BITMAPS_PER_BRUSH> bm; |
| 60 |
}; |
| 61 |
|
| 62 |
//Prototypes for IFF library functions |
| 63 |
|
| 64 |
[[nodiscard]] |
| 65 |
iff_status_code iff_read_bitmap(const char *ifilename, grs_bitmap &bm, palette_array_t *palette); |
| 66 |
//reads an IFF file into a grs_bitmap structure. fills in palette if not null |
| 67 |
//returns error codes - see IFF.H. see GR.H for bitmap_type |
| 68 |
//MEM DETAILS: This routines assumes that you already have the grs_bitmap |
| 69 |
//structure allocated, but that you don't have the data for this bitmap |
| 70 |
//allocated. In other words, do this: |
| 71 |
// grs_bitmap * MyPicture; |
| 72 |
// MALLOC( MyPicture, grs_bitmap, 1); |
| 73 |
// iff_read_bitmap( filename, MyPicture, bm_mode::linear, NULL ); |
| 74 |
// ...do whatever with your bitmap ... |
| 75 |
// gr_free_bitmap( MyPicture ); |
| 76 |
// exit(0) |
| 77 |
|
| 78 |
//read in animator brush (.abm) file |
| 79 |
//fills in array of pointers, and n_bitmaps. |
| 80 |
//returns iff error codes. max_bitmaps is size of array. |
| 81 |
iff_read_result iff_read_animbrush(const char *ifilename); |
| 82 |
|
| 83 |
// After a read |
| 84 |
extern ubyte iff_transparent_color; |
| 85 |
extern ubyte iff_has_transparency; // 0=no transparency, 1=iff_transparent_color is valid |
| 86 |
|
| 87 |
int iff_write_bitmap(const char *ofilename,grs_bitmap *bm,palette_array_t *palette); |
| 88 |
//writes an IFF file from a grs_bitmap structure. writes palette if not null |
| 89 |
//returns error codes - see IFF.H. |
| 90 |
|
| 91 |
//function to return pointer to error message |
| 92 |
[[nodiscard]] |
| 93 |
const char *iff_errormsg(iff_status_code error_number); |
| 94 |
|
| 95 |
#endif |
| 96 |
|