git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
first prototype of splaying active list
[swftools.git]
/
lib
/
gfxpoly
/
test.c
diff --git
a/lib/gfxpoly/test.c
b/lib/gfxpoly/test.c
index
aff9208
..
888e4d6
100644
(file)
--- a/
lib/gfxpoly/test.c
+++ b/
lib/gfxpoly/test.c
@@
-1,6
+1,5
@@
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
-#include <assert.h>
#include <memory.h>
#include <math.h>
#include "../gfxtools.h"
#include <memory.h>
#include <math.h>
#include "../gfxtools.h"
@@
-53,13
+52,13
@@
gfxline_t* mkchessboard()
unsigned int r = 0;
int spacing = 20;
unsigned int r = 0;
int spacing = 20;
- //int num_caros = 40;
- //int l = 5;
- //char do_centerpiece=1;
+ int num_caros = 40;
+ int l = 5;
+ char do_centerpiece=1;
- int num_caros = 4;
- int l=1;
- char do_centerpiece=0;
+ //int num_caros = 4;
+ //int l=1;
+ //char do_centerpiece=0;
for(x=-l;x<=l;x++)
for(y=-l;y<=l;y++) {
for(x=-l;x<=l;x++)
for(y=-l;y<=l;y++) {
@@
-138,7
+137,7
@@
int test0()
gfxpoly_destroy(poly);
}
gfxpoly_destroy(poly);
}
-int test1()
+int test1(int argn, char*argv[])
{
gfxline_t*box1 = gfxline_makerectangle(50,50,150,150);
// put box2 and box3 on top of each other *snicker*
{
gfxline_t*box1 = gfxline_makerectangle(50,50,150,150);
// put box2 and box3 on top of each other *snicker*
@@
-203,7
+202,7
@@
int test_square(int width, int height, int num, double gridsize, char bitmaptest
gfxpoly_destroy(poly);
}
gfxpoly_destroy(poly);
}
-int test2()
+int test2(int argn, char*argv[])
{
test_square(400,400, 3, 0.05, 1);
{
test_square(400,400, 3, 0.05, 1);
@@
-217,7
+216,7
@@
int test2()
}
#include "../rfxswf.h"
}
#include "../rfxswf.h"
-void test3()
+void test3(int argn, char*argv[])
{
#undef N
#undef RANGE
{
#undef N
#undef RANGE
@@
-251,7
+250,6
@@
void test3()
m.m11 = cos(t*M_PI/180.0);
m.tx = RANGE*1.41/2;
m.ty = RANGE*1.41/2;
m.m11 = cos(t*M_PI/180.0);
m.tx = RANGE*1.41/2;
m.ty = RANGE*1.41/2;
- printf("%d\n", t);
gfxline_t*l = gfxline_clone(line);
gfxline_transform(l, &m);
gfxline_t*l = gfxline_clone(line);
gfxline_transform(l, &m);
@@
-322,7
+320,7
@@
void test3()
}
#include <dirent.h>
}
#include <dirent.h>
-void test4()
+void test4(int argn, char*argv[])
{
char*dir = "ps";
DIR*_dir = opendir(dir);
{
char*dir = "ps";
DIR*_dir = opendir(dir);
@@
-335,10
+333,18
@@
void test4()
if(!strstr(file->d_name, ".ps"))
continue;
if(!strstr(file->d_name, ".ps"))
continue;
- char* filename = allocprintf("%s/%s", dir, file->d_name);
+ char* filename;
+
+ if(argn<2)
+ filename = allocprintf("%s/%s", dir, file->d_name);
+ else
+ filename = argv[1];
+
windrule_t*rule = &windrule_evenodd;
windrule_t*rule = &windrule_evenodd;
- gfxpoly_t*poly = gfxpoly_from_file(filename, 0.01);
- free(filename);
+ gfxpoly_t*poly = gfxpoly_from_file(filename, 1.0);//0.01);
+
+ if(argn!=2)
+ free(filename);
double zoom = 1.0;
intbbox_t bbox = intbbox_from_polygon(poly, zoom);
double zoom = 1.0;
intbbox_t bbox = intbbox_from_polygon(poly, zoom);
@@
-359,8
+365,14
@@
void test4()
save_two_bitmaps(&bbox, bitmap1, bitmap2, "error.png");
assert(!"bitmaps don't match");
}
save_two_bitmaps(&bbox, bitmap1, bitmap2, "error.png");
assert(!"bitmaps don't match");
}
+ free(bitmap1);
+ free(bitmap2);
+ gfxpoly_destroy(poly);
gfxpoly_destroy(poly2);
gfxpoly_destroy(poly2);
+ if(argn==2)
+ break;
}
}
+ closedir(_dir);
}
#include "../gfxdevice.h"
}
#include "../gfxdevice.h"
@@
-378,16
+390,16
@@
void extract_polygons_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
}
windrule_t*rule = &windrule_evenodd;
}
windrule_t*rule = &windrule_evenodd;
- gfxpoly_t*poly2 = gfxpoly_process(poly, rule);
double zoom = 1.0;
intbbox_t bbox = intbbox_from_polygon(poly, zoom);
unsigned char*bitmap1 = render_polygon(poly, &bbox, zoom, rule);
double zoom = 1.0;
intbbox_t bbox = intbbox_from_polygon(poly, zoom);
unsigned char*bitmap1 = render_polygon(poly, &bbox, zoom, rule);
- unsigned char*bitmap2 = render_polygon(poly2, &bbox, zoom, &windrule_evenodd);
if(!bitmap_ok(&bbox, bitmap1)) {
printf("bad polygon or error in renderer\n");
return;
}
if(!bitmap_ok(&bbox, bitmap1)) {
printf("bad polygon or error in renderer\n");
return;
}
+ gfxpoly_t*poly2 = gfxpoly_process(poly, rule);
+ unsigned char*bitmap2 = render_polygon(poly2, &bbox, zoom, &windrule_evenodd);
if(!bitmap_ok(&bbox, bitmap2)) {
save_two_bitmaps(&bbox, bitmap1, bitmap2, "error.png");
assert(!"error in bitmap");
if(!bitmap_ok(&bbox, bitmap2)) {
save_two_bitmaps(&bbox, bitmap1, bitmap2, "error.png");
assert(!"error in bitmap");
@@
-396,6
+408,8
@@
void extract_polygons_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
save_two_bitmaps(&bbox, bitmap1, bitmap2, "error.png");
assert(!"bitmaps don't match");
}
save_two_bitmaps(&bbox, bitmap1, bitmap2, "error.png");
assert(!"bitmaps don't match");
}
+ free(bitmap1);
+ free(bitmap2);
gfxpoly_destroy(poly);
gfxpoly_destroy(poly2);
gfxpoly_destroy(poly);
gfxpoly_destroy(poly2);
@@
-456,8
+470,9
@@
finish: 0,
internal: 0
};
internal: 0
};
-void test5()
+void test5(int argn, char*argv[])
{
{
+ gfxsource_t*driver = gfxsource_pdf_create();
char*dir = "pdfs";
DIR*_dir = opendir(dir);
if(!_dir) return;
char*dir = "pdfs";
DIR*_dir = opendir(dir);
if(!_dir) return;
@@
-470,7
+485,6
@@
void test5()
continue;
char* filename = allocprintf("%s/%s", dir, file->d_name);
continue;
char* filename = allocprintf("%s/%s", dir, file->d_name);
- gfxsource_t*driver = gfxsource_pdf_create();
gfxdocument_t*doc = driver->open(driver, filename);
gfxdevice_t*out = &extract_polygons;
int t;
gfxdocument_t*doc = driver->open(driver, filename);
gfxdevice_t*out = &extract_polygons;
int t;
@@
-479,13
+493,15
@@
void test5()
gfxpage_t* page = doc->getpage(doc, t);
page->render(page, out);
page->destroy(page);
gfxpage_t* page = doc->getpage(doc, t);
page->render(page, out);
page->destroy(page);
- break;
}
}
+ doc->destroy(doc);
free(filename);
}
free(filename);
}
+ closedir(_dir);
+ driver->destroy(driver);
}
}
-int main()
+int main(int argn, char*argv[])
{
{
- test0();
+ test5(argn, argv);
}
}