File: basic.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 (37 lines) | stat: -rw-r--r-- 1,022 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
/* Testing basic gdImageCopyResampled() functionality */

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

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

	im = gdImageCreateTrueColor(400, 300);

	/* allocate some colors */
	white = gdImageColorAllocate(im, 255, 255, 255);
	yellow = gdImageColorAllocate(im, 128, 0, 128);
	magenta = gdImageColorAllocate(im, 128, 128, 0);
	cyan = gdImageColorAllocate(im, 0, 128, 128);

	/* 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);
	gdImageCopyResampled(copy, im, 0,0, 0,0, 200,200, 400,300);
	gdImageDestroy(im);

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

	gdImageDestroy(copy);
	return gdNumFailures();
}