13
13
/* Changes: 28.11.1997 Noninteractive operation */
14
14
/* 16.03.1998 Endian-independent!! */
15
/* 21.03.1998 Little Bug-fix */
15
/* 21.03.1998 Little Bug-fix */
16
16
/* 06.04.1998 Bugfix in Padding */
17
17
/* 11.04.1998 Arch. cleanup (-Wall) */
27
27
/* 06.05.2000 Overhaul for 16&24-bit */
28
28
/* plus better OS/2 code */
29
29
/* by njl195@zepler.org.uk */
30
/* 29.06.2006 Full support for 16/32 */
31
/* bits bitmaps and support */
32
/* for alpha channel */
33
/* by p.filiciak@zax.pl */
32
* The GIMP -- an image manipulation program
36
* GIMP - The GNU Image Manipulation Program
33
37
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
35
39
* This program is free software; you can redistribute it and/or modify
64
65
#include "libgimp/stdplugins-intl.h"
66
const gchar *filename = NULL;
67
gboolean interactive_bmp;
68
const gchar *filename = NULL;
69
gboolean interactive = FALSE;
70
gboolean lastvals = FALSE;
69
72
struct Bitmap_File_Head_Struct Bitmap_File_Head;
70
struct Bitmap_Head_Struct Bitmap_Head;
73
struct Bitmap_Head_Struct Bitmap_Head;
72
76
/* Declare some local functions.
94
static GimpParamDef load_args[] =
98
static const GimpParamDef load_args[] =
96
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
100
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
97
101
{ GIMP_PDB_STRING, "filename", "The name of the file to load" },
98
{ GIMP_PDB_STRING, "raw_filename", "The name entered" },
102
{ GIMP_PDB_STRING, "raw-filename", "The name entered" },
100
static GimpParamDef load_return_vals[] =
104
static const GimpParamDef load_return_vals[] =
102
106
{ GIMP_PDB_IMAGE, "image", "Output image" },
105
static GimpParamDef save_args[] =
109
static const GimpParamDef save_args[] =
107
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
111
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
108
112
{ GIMP_PDB_IMAGE, "image", "Input image" },
109
113
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save" },
110
114
{ GIMP_PDB_STRING, "filename", "The name of the file to save the image in" },
111
{ GIMP_PDB_STRING, "raw_filename", "The name entered" },
115
{ GIMP_PDB_STRING, "raw-filename", "The name entered" },
114
gimp_install_procedure ("file_bmp_load",
118
gimp_install_procedure (LOAD_PROC,
115
119
"Loads files of Windows BMP file format",
116
120
"Loads files of Windows BMP file format",
117
121
"Alexander Schulz",
124
128
G_N_ELEMENTS (load_return_vals),
125
129
load_args, load_return_vals);
127
gimp_register_file_handler_mime ("file_bmp_load", "image/bmp");
128
gimp_register_magic_load_handler ("file_bmp_load",
131
gimp_register_file_handler_mime (LOAD_PROC, "image/bmp");
132
gimp_register_magic_load_handler (LOAD_PROC,
133
gimp_install_procedure ("file_bmp_save",
137
gimp_install_procedure (SAVE_PROC,
134
138
"Saves files in Windows BMP file format",
135
139
"Saves files in Windows BMP file format",
136
140
"Alexander Schulz",
137
141
"Alexander Schulz",
139
143
N_("Windows BMP image"),
140
"INDEXED, GRAY, RGB",
144
"INDEXED, GRAY, RGB*",
142
146
G_N_ELEMENTS (save_args), 0,
143
147
save_args, NULL);
145
gimp_register_file_handler_mime ("file_bmp_save", "image/bmp");
146
gimp_register_save_handler ("file_bmp_save", "bmp", "");
149
gimp_register_file_handler_mime (SAVE_PROC, "image/bmp");
150
gimp_register_save_handler (SAVE_PROC, "bmp", "");
169
173
values[0].type = GIMP_PDB_STATUS;
170
174
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
172
if (strcmp (name, "file_bmp_load") == 0)
176
if (strcmp (name, LOAD_PROC) == 0)
174
178
switch (run_mode)
176
180
case GIMP_RUN_INTERACTIVE:
177
interactive_bmp = TRUE;
180
184
case GIMP_RUN_NONINTERACTIVE:
181
185
/* Make sure all the arguments are there! */
182
interactive_bmp = FALSE;
184
187
status = GIMP_PDB_CALLING_ERROR;
191
194
if (status == GIMP_PDB_SUCCESS)
193
image_ID = ReadBMP (param[1].data.d_string);
196
image_ID = ReadBMP (param[1].data.d_string);
198
values[1].type = GIMP_PDB_IMAGE;
199
values[1].data.d_image = image_ID;
203
status = GIMP_PDB_EXECUTION_ERROR;
201
values[1].type = GIMP_PDB_IMAGE;
202
values[1].data.d_image = image_ID;
206
status = GIMP_PDB_EXECUTION_ERROR;
207
else if (strcmp (name, "file_bmp_save") == 0)
210
else if (strcmp (name, SAVE_PROC) == 0)
209
212
image_ID = param[1].data.d_int32;
210
213
drawable_ID = param[2].data.d_int32;
212
215
/* eventually export the image */
213
216
switch (run_mode)
215
case GIMP_RUN_INTERACTIVE:
216
case GIMP_RUN_WITH_LAST_VALS:
217
gimp_ui_init ("bmp", FALSE);
218
export = gimp_export_image (&image_ID, &drawable_ID, "BMP",
219
(GIMP_EXPORT_CAN_HANDLE_RGB |
220
GIMP_EXPORT_CAN_HANDLE_GRAY |
221
GIMP_EXPORT_CAN_HANDLE_INDEXED));
222
if (export == GIMP_EXPORT_CANCEL)
224
values[0].data.d_status = GIMP_PDB_CANCEL;
234
218
case GIMP_RUN_INTERACTIVE:
235
interactive_bmp = TRUE;
238
case GIMP_RUN_NONINTERACTIVE:
239
/* Make sure all the arguments are there! */
240
interactive_bmp = FALSE;
242
status = GIMP_PDB_CALLING_ERROR;
245
222
case GIMP_RUN_WITH_LAST_VALS:
246
interactive_bmp = FALSE;
223
if (run_mode == GIMP_RUN_WITH_LAST_VALS) lastvals = TRUE;
224
gimp_ui_init ("bmp", FALSE);
225
export = gimp_export_image (&image_ID, &drawable_ID, "BMP",
226
(GIMP_EXPORT_CAN_HANDLE_RGB |
227
GIMP_EXPORT_CAN_HANDLE_ALPHA |
228
GIMP_EXPORT_CAN_HANDLE_GRAY |
229
GIMP_EXPORT_CAN_HANDLE_INDEXED));
231
if (export == GIMP_EXPORT_CANCEL)
233
values[0].data.d_status = GIMP_PDB_CANCEL;
238
case GIMP_RUN_NONINTERACTIVE:
239
/* Make sure all the arguments are there! */
241
status = GIMP_PDB_CALLING_ERROR;
253
248
if (status == GIMP_PDB_SUCCESS)
255
status = WriteBMP (param[3].data.d_string, image_ID, drawable_ID);
249
status = WriteBMP (param[3].data.d_string, image_ID, drawable_ID);
258
251
if (export == GIMP_EXPORT_EXPORT)
259
gimp_image_delete (image_ID);
252
gimp_image_delete (image_ID);