comparison src/libgfx.c @ 1290:e7dc9bb9777e

Rename struct DMImageSpec to DMImageConvSpec.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 18 Aug 2017 17:47:30 +0300
parents 6c8b19d1d196
children 2c4acbc3e7bf
comparison
equal deleted inserted replaced
1289:4b025a96ad46 1290:e7dc9bb9777e
135 135
136 return TRUE; 136 return TRUE;
137 } 137 }
138 138
139 139
140 int dmImageConvertTo(DMImage **dst, const DMImage *src, const DMImageSpec *spec) 140 int dmImageConvertTo(DMImage **dst, const DMImage *src, const DMImageConvSpec *spec)
141 { 141 {
142 return DMERR_OK; 142 return DMERR_OK;
143 } 143 }
144 144
145 145
146 int dmWriteImageData(DMImage *img, void *cbdata, int (*writeRowCB)(void *, Uint8 *, size_t), const DMImageSpec *spec) 146 int dmWriteImageData(DMImage *img, void *cbdata, int (*writeRowCB)(void *, Uint8 *, size_t), const DMImageConvSpec *spec)
147 { 147 {
148 int x, y, yscale, xscale, res = 0, rowSize, rowWidth; 148 int x, y, yscale, xscale, res = 0, rowSize, rowWidth;
149 Uint8 *row = NULL; 149 Uint8 *row = NULL;
150 150
151 // Allocate memory for row buffer 151 // Allocate memory for row buffer
258 258
259 return DMERR_OK; 259 return DMERR_OK;
260 } 260 }
261 261
262 262
263 int dmWriteRAWImageFILE(FILE *fp, DMImage *img, const DMImageSpec *spec) 263 int dmWriteRAWImageFILE(FILE *fp, DMImage *img, const DMImageConvSpec *spec)
264 { 264 {
265 int xc, yc, plane, res; 265 int xc, yc, plane, res;
266 DMBitStreamContext bs; 266 DMBitStreamContext bs;
267 267
268 if ((res = dmInitBitStreamFILE(&bs, fp)) != DMERR_OK) 268 if ((res = dmInitBitStreamFILE(&bs, fp)) != DMERR_OK)
303 303
304 return dmFlushBitStream(&bs); 304 return dmFlushBitStream(&bs);
305 } 305 }
306 306
307 307
308 int dmWriteRAWImage(const char *filename, DMImage *img, const DMImageSpec *spec) 308 int dmWriteRAWImage(const char *filename, DMImage *img, const DMImageConvSpec *spec)
309 { 309 {
310 FILE *fp; 310 FILE *fp;
311 int res; 311 int res;
312 312
313 if ((fp = fopen(filename, "wb")) == NULL) 313 if ((fp = fopen(filename, "wb")) == NULL)
331 else 331 else
332 return DMERR_FWRITE; 332 return DMERR_FWRITE;
333 } 333 }
334 334
335 335
336 int dmWritePPMImageFILE(FILE *fp, DMImage *img, const DMImageSpec *spec) 336 int dmWritePPMImageFILE(FILE *fp, DMImage *img, const DMImageConvSpec *spec)
337 { 337 {
338 DMImageSpec tmpSpec; 338 DMImageConvSpec tmpSpec;
339 339
340 // Write PPM header 340 // Write PPM header
341 fprintf(fp, 341 fprintf(fp,
342 "P6\n%d %d\n255\n", 342 "P6\n%d %d\n255\n",
343 img->width * spec->scaleX, 343 img->width * spec->scaleX,
344 img->height * spec->scaleY); 344 img->height * spec->scaleY);
345 345
346 // Write image data 346 // Write image data
347 memcpy(&tmpSpec, spec, sizeof(DMImageSpec)); 347 memcpy(&tmpSpec, spec, sizeof(DMImageConvSpec));
348 tmpSpec.format = DM_IFMT_RGB; 348 tmpSpec.format = DM_IFMT_RGB;
349 return dmWriteImageData(img, (void *) fp, dmWritePPMRow, &tmpSpec); 349 return dmWriteImageData(img, (void *) fp, dmWritePPMRow, &tmpSpec);
350 } 350 }
351 351
352 352
353 int dmWritePPMImage(const char *filename, DMImage *img, const DMImageSpec *spec) 353 int dmWritePPMImage(const char *filename, DMImage *img, const DMImageConvSpec *spec)
354 { 354 {
355 FILE *fp; 355 FILE *fp;
356 int res; 356 int res;
357 357
358 // Create output file 358 // Create output file
383 383
384 return DMERR_OK; 384 return DMERR_OK;
385 } 385 }
386 386
387 387
388 int dmWritePNGImageFILE(FILE *fp, DMImage *img, const DMImageSpec *spec) 388 int dmWritePNGImageFILE(FILE *fp, DMImage *img, const DMImageConvSpec *spec)
389 { 389 {
390 png_structp png_ptr = NULL; 390 png_structp png_ptr = NULL;
391 png_infop info_ptr = NULL; 391 png_infop info_ptr = NULL;
392 int fmt, res = DMERR_OK; 392 int fmt, res = DMERR_OK;
393 393
490 490
491 return res; 491 return res;
492 } 492 }
493 493
494 494
495 int dmWritePNGImage(const char *filename, DMImage *img, const DMImageSpec *spec) 495 int dmWritePNGImage(const char *filename, DMImage *img, const DMImageConvSpec *spec)
496 { 496 {
497 int res; 497 int res;
498 FILE *fp; 498 FILE *fp;
499 499
500 if ((fp = fopen(filename, "wb")) == NULL) 500 if ((fp = fopen(filename, "wb")) == NULL)
820 820
821 return DMERR_OK; 821 return DMERR_OK;
822 } 822 }
823 823
824 824
825 int dmWritePCXImageFILE(FILE *fp, DMImage *img, const DMImageSpec *spec) 825 int dmWritePCXImageFILE(FILE *fp, DMImage *img, const DMImageConvSpec *spec)
826 { 826 {
827 DMPCXData pcx; 827 DMPCXData pcx;
828 DMPCXHeader hdr; 828 DMPCXHeader hdr;
829 int res; 829 int res;
830 830
949 dmFree(pcx.buf); 949 dmFree(pcx.buf);
950 return res; 950 return res;
951 } 951 }
952 952
953 953
954 int dmWritePCXImage(const char *filename, DMImage *img, const DMImageSpec *spec) 954 int dmWritePCXImage(const char *filename, DMImage *img, const DMImageConvSpec *spec)
955 { 955 {
956 FILE *fp; 956 FILE *fp;
957 int res; 957 int res;
958 958
959 if ((fp = fopen(filename, "wb")) == NULL) 959 if ((fp = fopen(filename, "wb")) == NULL)