...
|
...
|
@@ -6,6 +6,7 @@
|
6
|
6
|
*
|
7
|
7
|
* History:
|
8
|
8
|
* 28/06/2019 Creation
|
|
9
|
+ * 27/01/2024 Support transparency
|
9
|
10
|
*
|
10
|
11
|
* Author: Dario Rodriguez dario@softhome.net
|
11
|
12
|
* This program is distributed under the terms of the GNU GPL v2.1+
|
...
|
...
|
@@ -19,7 +20,9 @@ main(int argc, array(string) argv)
|
19
|
20
|
string origfilename;
|
20
|
21
|
string resprefix;
|
21
|
22
|
int x,y,total;
|
22
|
|
- Image.Image img,cropped;
|
|
23
|
+ mapping imagemapping;
|
|
24
|
+ Image.Image image,alpha,cropped,croppedalpha;
|
|
25
|
+ Image.Layer l;
|
23
|
26
|
string outfilename;
|
24
|
27
|
if(argc<4 || (argc>1 && argv[1]=="--help")) {
|
25
|
28
|
Stdio.werror("Syntax: "+argv[0]+" <width_in_a4pages> <height_in_a4_pages> <origimage.png>\n");
|
...
|
...
|
@@ -32,16 +35,21 @@ main(int argc, array(string) argv)
|
32
|
35
|
origfilename=argv[3];
|
33
|
36
|
resprefix=(origfilename/".png")[0];
|
34
|
37
|
write("* Loading "+origfilename+"...\n");
|
35
|
|
- img=Image.load(origfilename);
|
36
|
|
- px=img->xsize()/a4w;
|
37
|
|
- py=img->ysize()/a4h;
|
|
38
|
+ imagemapping=Image._load(origfilename);
|
|
39
|
+ image=imagemapping["image"];
|
|
40
|
+ alpha=imagemapping["alpha"];
|
|
41
|
+ px=image->xsize()/a4w;
|
|
42
|
+ py=image->ysize()/a4h;
|
38
|
43
|
for(total=0,y=0;y<a4h;y++) {
|
39
|
44
|
for(x=0;x<a4w;x++) {
|
40
|
45
|
total++;
|
41
|
|
- cropped=img->copy(x*px,y*py,(x+1)*px-1,(y+1)*py-1,255,255,255);
|
|
46
|
+ cropped=image->copy(x*px,y*py,(x+1)*px-1,(y+1)*py-1,255,255,255);
|
|
47
|
+ croppedalpha=alpha->copy(x*px,y*py,(x+1)*px-1,(y+1)*py-1,255,255,255);
|
|
48
|
+ l=Image.Layer(cropped,croppedalpha,"normal");
|
|
49
|
+ l->set_offset(0,0);
|
42
|
50
|
outfilename=sprintf("%s_%05d.png",resprefix,total);
|
43
|
51
|
write("* Writing "+outfilename+"...\n");
|
44
|
|
- Stdio.write_file(outfilename,Image.PNG.encode(cropped));
|
|
52
|
+ Stdio.write_file(outfilename,Image.PNG.encode(l->image(),(["alpha":l->alpha()])));
|
45
|
53
|
}
|
46
|
54
|
}
|
47
|
55
|
write(""+total+" slices written. Process finished.\n");
|