summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2010-09-03 16:35:32 +0000
committerManolo Gouy <Manolo>2010-09-03 16:35:32 +0000
commit0dc7b5edc58def3839f05e8692f060aa47b18e2c (patch)
tree943fa2796123ad83cb7037cfd564f89872ff8535
parent71bf7c64008012f7ebacda04ca89cc2f1d68848c (diff)
PostScript output of Fl_Pixmap objects: accept now arbitrarily large pixmaps
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7695 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl_PostScript.cxx28
-rw-r--r--src/ps_image.cxx54
2 files changed, 34 insertions, 48 deletions
diff --git a/src/Fl_PostScript.cxx b/src/Fl_PostScript.cxx
index 4f6eb2c10..7653f8504 100644
--- a/src/Fl_PostScript.cxx
+++ b/src/Fl_PostScript.cxx
@@ -330,8 +330,6 @@ static const char * prolog_2 = // prolog relevant only if lang_level >1
"IDD image GR} bind def\n"
// gray image dict
-
-
"/GII {GS /inter exch def /py exch def /px exch def /sy exch def /sx exch def \n"
"translate \n"
"sx sy scale\n"
@@ -370,9 +368,7 @@ static const char * prolog_2 = // prolog relevant only if lang_level >1
"/Times-BoldItalic ToLatin1 \n"
;
-static const char * prolog_2_pixmap = // prolog relevant only if lang_level == 2 for pixmaps
-"/pixmap_size { /pixmap_sy exch def /pixmap_sx exch def } bind def\n"
-
+static const char * prolog_2_pixmap = // prolog relevant only if lang_level == 2 for pixmaps/masked color images
"/pixmap_mat {[ pixmap_sx 0 0 pixmap_sy neg 0 pixmap_sy ]} bind def\n"
"/pixmap_dict {"
@@ -384,10 +380,10 @@ static const char * prolog_2_pixmap = // prolog relevant only if lang_level ==
"/YStep pixmap_sy\n"
"/PaintProc "
"{ begin "
-"pixmap_sx pixmap_sy scale "
+"pixmap_w pixmap_h scale "
"pixmap_sx pixmap_sy 8 "
"pixmap_mat "
-"pixmap_data "
+"currentfile /ASCIIHexDecode filter "
"false 3 "
"colorimage "
"end "
@@ -397,28 +393,20 @@ static const char * prolog_2_pixmap = // prolog relevant only if lang_level ==
"/pixmap_plot {"
"GS "
-"/pixmap_y exch def /pixmap_x exch def\n"
-"pixmap_x pixmap_y translate\n"
+"/pixmap_sy exch def /pixmap_sx exch def\n"
+"/pixmap_h exch def /pixmap_w exch def\n"
+"translate\n"
"pixmap_dict matrix makepattern setpattern\n"
-"pixmap_sx pixmap_sy scale\n"
+"pixmap_w pixmap_h scale\n"
"pixmap_sx pixmap_sy\n"
"true\n"
"pixmap_mat\n"
-"pixmap_mask\n"
+"currentfile /ASCIIHexDecode filter\n"
"imagemask\n"
"GR\n"
"} bind def\n"
-
-"/pixmap_loaddata { /pixmap_data currentfile pixmap_sx pixmap_sy 3 mul mul string readhexstring "
-"} bind def\n"
-
-"/pixmap_loadmask { "
-"/pixmap_mask currentfile pixmap_sx 8 div ceiling cvi pixmap_sy mul string readhexstring "
-"} bind def\n"
;
-
-
static const char * prolog_3 = // prolog relevant only if lang_level >2
// masked color images
diff --git a/src/ps_image.cxx b/src/ps_image.cxx
index 51646efa6..e60797764 100644
--- a/src/ps_image.cxx
+++ b/src/ps_image.cxx
@@ -277,7 +277,7 @@ void Fl_PostScript_Graphics_Driver::draw_scaled_image(Fl_Draw_Image_Cb call, voi
}
else if (mask && lang_level_ == 2) {
level2_mask = 1; // use method for drawing masked color image with PostScript level 2
- fprintf(output, "%d %d pixmap_size\n pixmap_loadmask\n", iw, ih);
+ fprintf(output, " %g %g %g %g %d %d pixmap_plot\n", x, y, w, h, iw, ih);
}
else {
fprintf(output, "%g %g %g %g %i %i %s CII\n", x , y+h , w , -h , iw , ih, interpol);
@@ -291,38 +291,36 @@ void Fl_PostScript_Graphics_Driver::draw_scaled_image(Fl_Draw_Image_Cb call, voi
uchar *curmask=mask;
if(level2_mask) {
- for (j = ih - 1; j >= 0; j--) {
- curmask = mask + j * my/ih * ((mx+7)/8);
- for(k=0; k < my/ih; k++) { // output mask data
- for (i=0; i < ((mx+7)/8); i++) {
- fprintf(output, "%.2x",swap_byte(*curmask));
- curmask++;
- }
- fprintf(output,"\n");
- }
- }
- fprintf(output,"pop def\n\npixmap_loaddata\n");
for (j = ih - 1; j >= 0; j--) { // output full image data
- call(data,0,j,iw,rgbdata);
- uchar *curdata=rgbdata;
- for(i=0 ; i<iw ; i++) {
- uchar r = curdata[0];
- uchar g = curdata[1];
- uchar b = curdata[2];
- //if (!(i%40)) fprintf(output, "\n");
- fprintf(output, "%.2x%.2x%.2x", r, g, b);
+ call(data, 0, j, iw, rgbdata);
+ uchar *curdata = rgbdata;
+ for (i=0 ; i<iw ; i++) {
+ if (!(i%20)) fputs("\n", output);
+ fprintf(output, "%.2x%.2x%.2x", curdata[0], curdata[1], curdata[2]);
curdata += D;
}
- fprintf(output,"\n");
+ fputs("\n", output);
+ }
+ fputs(">\n", output);
+ for (j = ih - 1; j >= 0; j--) { // output mask data
+ curmask = mask + j * (my/ih) * ((mx+7)/8);
+ for (k=0; k < my/ih; k++) {
+ for (i=0; i < ((mx+7)/8); i++) {
+ if (!(i%40)) fputs("\n", output);
+ fprintf(output, "%.2x",swap_byte(*curmask));
+ curmask++;
+ }
+ fputs("\n", output);
}
- fprintf(output,"pop def\n\n%g %g pixmap_plot\n", x, y); // draw the masked image
}
+ fputs(">\n", output);
+ }
else {
for (j=0; j<ih;j++) {
if(mask && lang_level_ > 2) { // InterleaveType 2 mask data
- for(k=0; k<my/ih;k++) { //for alpha pseudo-masking
+ for (k=0; k<my/ih;k++) { //for alpha pseudo-masking
for (i=0; i<((mx+7)/8);i++) {
- if (!(i%40)) fprintf(output, "\n");
+ if (!(i%40)) fputs("\n", output);
fprintf(output, "%.2x",swap_byte(*curmask));
curmask++;
}
@@ -331,20 +329,20 @@ void Fl_PostScript_Graphics_Driver::draw_scaled_image(Fl_Draw_Image_Cb call, voi
}
call(data,0,j,iw,rgbdata);
uchar *curdata=rgbdata;
- for(i=0 ; i<iw ; i++) {
+ for (i=0 ; i<iw ; i++) {
uchar r = curdata[0];
uchar g = curdata[1];
uchar b = curdata[2];
- if (!(i%40)) fprintf(output, "\n");
+ if (!(i%40)) fputs("\n", output);
fprintf(output, "%.2x%.2x%.2x", r, g, b);
curdata +=D;
}
- fprintf(output,"\n");
+ fputs("\n", output);
}
- fprintf(output,">\n");
+ fputs(">\n", output);
}
fprintf(output,"restore\n");