comparison tools/libgfx.c @ 2098:e38705223ce4

Support grayscale output.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Mar 2019 12:14:31 +0200
parents 6b2bac1e3445
children 81fb21dd3265
comparison
equal deleted inserted replaced
2097:f43011ea9b9f 2098:e38705223ce4
334 Uint8 *ptr1 = row, 334 Uint8 *ptr1 = row,
335 *ptr2 = ptr1 + rowWidth, 335 *ptr2 = ptr1 + rowWidth,
336 *ptr3 = ptr2 + rowWidth, 336 *ptr3 = ptr2 + rowWidth,
337 *ptr4 = ptr3 + rowWidth; 337 *ptr4 = ptr3 + rowWidth;
338 338
339 if (img->format == DM_COLFMT_PALETTE || 339 if (img->format == DM_COLFMT_GRAYSCALE)
340 img->format == DM_COLFMT_GRAYSCALE) 340 {
341 for (x = 0; x < img->width; x++)
342 {
343 Uint8 c = img->data[(y * img->pitch) + (x * img->bpp) / 8];
344
345 switch (spec->format)
346 {
347 case DM_COLFMT_PALETTE:
348 case DM_COLFMT_GRAYSCALE:
349 for (xscale = 0; xscale < spec->scaleX; xscale++)
350 *ptr1++ = c;
351 break;
352
353 case DM_COLFMT_RGBA:
354 if (spec->planar)
355 {
356 for (xscale = 0; xscale < spec->scaleX; xscale++)
357 {
358 *ptr1++ = c;
359 *ptr2++ = c;
360 *ptr3++ = c;
361 *ptr4++ = 0xff;
362 }
363 }
364 else
365 {
366 for (xscale = 0; xscale < spec->scaleX; xscale++)
367 {
368 *ptr1++ = c;
369 *ptr1++ = c;
370 *ptr1++ = c;
371 *ptr1++ = 0xff;
372 }
373 }
374 break;
375
376 case DM_COLFMT_RGB:
377 if (spec->planar)
378 {
379 for (xscale = 0; xscale < spec->scaleX; xscale++)
380 {
381 *ptr1++ = c;
382 *ptr2++ = c;
383 *ptr3++ = c;
384 }
385 }
386 else
387 {
388 for (xscale = 0; xscale < spec->scaleX; xscale++)
389 {
390 *ptr1++ = c;
391 *ptr1++ = c;
392 *ptr1++ = c;
393 }
394 }
395 break;
396
397 default:
398 res = DMERR_NOT_SUPPORTED;
399 goto done;
400 }
401 }
402 }
403 else
404 if (img->format == DM_COLFMT_PALETTE)
341 { 405 {
342 for (x = 0; x < img->width; x++) 406 for (x = 0; x < img->width; x++)
343 { 407 {
344 Uint8 c = img->data[(y * img->pitch) + (x * img->bpp) / 8], 408 Uint8 c = img->data[(y * img->pitch) + (x * img->bpp) / 8],
345 qr, qg, qb, qa; 409 qr, qg, qb, qa;