File: basic_alpha.c

package info (click to toggle)
libgd2 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 10,360 kB
  • sloc: ansic: 48,194; sh: 5,603; cpp: 1,298; makefile: 323; perl: 225; tcl: 45
file content (40 lines) | stat: -rw-r--r-- 1,180 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Testing basic gdImageCopyResampled() functionality with alpha channel */

#include "gd.h"
#include "gdtest.h"

int main()
{
	gdImagePtr im, copy;
	int white, yellow, magenta, cyan;

	im = gdImageCreateTrueColor(400, 300);
	gdImageAlphaBlending(im, 0);

	/* allocate some alpha colors */
	white = gdImageColorAllocateAlpha(im, 255, 255, 255, 31);
	yellow = gdImageColorAllocateAlpha(im, 128, 0, 128, 63);
	magenta = gdImageColorAllocateAlpha(im, 128, 128, 0, 95);
	cyan = gdImageColorAllocateAlpha(im, 0, 128, 128, 127);

	/* draw background */
	gdImageFilledRectangle(im, 0,0, 399,299, white);

	/* draw some basic shapes */
	gdImageFilledEllipse(im, 100,100, 150,100, yellow);
	gdImageSetThickness(im, 5);
	gdImageLine(im, 50,250, 350,50, magenta);
	gdImageRectangle(im, 200,100, 350,250, cyan);

	/* create a diminished, resampled copy of the original image */
	copy = gdImageCreateTrueColor(200, 200);
	gdImageAlphaBlending(copy, 0);
	gdImageSaveAlpha(copy, 1);
	gdImageCopyResampled(copy, im, 0,0, 0,0, 200,200, 400,300);
	gdImageDestroy(im);

	gdAssertImageEqualsToFile("gdimagecopyresampled/basic_alpha_exp.png", copy);

	gdImageDestroy(copy);
	return gdNumFailures();
}