~ubuntu-branches/ubuntu/raring/vice/raring

« back to all changes in this revision

Viewing changes to src/gfxoutputdrv/gifdrv.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2009-03-31 00:37:15 UTC
  • mfrom: (1.1.7 upstream) (9.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090331003715-i5yisvcfv7mgz3eh
Tags: 2.1.dfsg-1
* New major upstream release (closes: #495937).
* Add desktop files (closes: #501181).

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
  return 0;
162
162
}
163
163
 
 
164
#ifdef FEATURE_CPUMEMHISTORY
 
165
static GifFileType *gifdrv_memmap_fd;
 
166
static char *gifdrv_memmap_ext_filename;
 
167
 
 
168
static int gifdrv_close_memmap(void)
 
169
{
 
170
  EGifCloseFile(gifdrv_memmap_fd);
 
171
  FreeMapObject(gif_colors);
 
172
  lib_free(gifdrv_memmap_ext_filename);
 
173
 
 
174
  return 0;
 
175
}
 
176
 
 
177
static int gifdrv_write_memmap(int line, int x_size, BYTE *gfx)
 
178
{
 
179
  if (EGifPutLine(gifdrv_memmap_fd, gfx+(line*x_size), x_size)==GIF_ERROR)
 
180
    return -1;
 
181
 
 
182
  return 0;
 
183
}
 
184
 
 
185
static int gifdrv_open_memmap(const char *filename, int x_size, int y_size, BYTE *palette)
 
186
{
 
187
  unsigned int i;
 
188
  GifColorType ColorMap256[256];
 
189
 
 
190
  gifdrv_memmap_ext_filename=util_add_extension_const(filename, gif_drv.default_extension);
 
191
 
 
192
  gifdrv_memmap_fd=EGifOpenFileName(gifdrv_memmap_ext_filename, FALSE);
 
193
 
 
194
  if (gifdrv_memmap_fd==NULL)
 
195
  {
 
196
    lib_free(gifdrv_memmap_ext_filename);
 
197
    return -1;
 
198
  }
 
199
 
 
200
  gif_colors=MakeMapObject(256, ColorMap256);
 
201
 
 
202
  for (i = 0; i < 256; i++)
 
203
  {
 
204
    gif_colors->Colors[i].Blue=palette[(i*3)+2];
 
205
    gif_colors->Colors[i].Green=palette[(i*3)+1];
 
206
    gif_colors->Colors[i].Red=palette[i*3];
 
207
  }
 
208
 
 
209
  EGifSetGifVersion("87a");
 
210
 
 
211
  if (EGifPutScreenDesc(gifdrv_memmap_fd, x_size, y_size, 8, 0, gif_colors) == GIF_ERROR ||
 
212
      EGifPutImageDesc(gifdrv_memmap_fd, 0, 0, x_size, y_size, FALSE, NULL) == GIF_ERROR)
 
213
  {
 
214
    EGifCloseFile(gifdrv_memmap_fd);
 
215
    FreeMapObject(gif_colors);
 
216
    lib_free(gifdrv_memmap_ext_filename);
 
217
    return -1;
 
218
  }
 
219
 
 
220
  return 0;
 
221
}
 
222
 
 
223
static int gifdrv_save_memmap(const char *filename, int x_size, int y_size, BYTE *gfx, BYTE *palette)
 
224
{
 
225
  int line;
 
226
 
 
227
  if (gifdrv_open_memmap(filename, x_size, y_size, palette) < 0)
 
228
    return -1;
 
229
 
 
230
  for (line = 0; line < y_size; line++)
 
231
  {
 
232
    gifdrv_write_memmap(line, x_size, gfx);
 
233
  }
 
234
 
 
235
  if (gifdrv_close_memmap() < 0)
 
236
    return -1;
 
237
 
 
238
  return 0;
 
239
}
 
240
#endif
 
241
 
164
242
static gfxoutputdrv_t gif_drv =
165
243
{
166
244
    "GIF",
170
248
    gifdrv_close,
171
249
    gifdrv_write,
172
250
    gifdrv_save,
 
251
#ifdef FEATURE_CPUMEMHISTORY
 
252
    NULL,
 
253
    gifdrv_save_memmap
 
254
#else
173
255
    NULL
 
256
#endif
174
257
};
175
258
 
176
259
void gfxoutput_init_gif(void)