Generate postscript file PS-Adobe EPSF android

53 views Asked by At

Hi Currenlty i'm generating postscript file in android, It's printed as colored. I want to print in black & white. I tried "/DeviceGrey" but got an error. Can anyone help me out?

        wr("%!PS-Adobe-3.0 EPSF-3.0");
        wr("%%BoundingBox: 0 0 " + width + " " + height);
        // wr("%%Title: otz.bunny.jpeg");
        // wr("%%Creator: James's JPEG encapsulator - /home/james/etc/jpeg2eps");
        wr("%%CreationDate: " + new Date());
        wr("%%LanguageLevel: 2");
        wr("%%Pages: 1");
        wr("%%EndComments");
        wr("%%Page: 1 1");
        wr("/WIDTH " + width + " def");
        wr("/HEIGHT " + height + " def");
        wr("/DPI " + dpi + " def");
        wr("DPI dup scale");
        wr("/DeviceGray setcolorspace");
        wr("<<");
        wr(" /ImageType 1");
        wr(" /Width WIDTH");
        wr(" /Height HEIGHT");
        wr(" /BitsPerComponent 8");
        wr(" /Decode [0 1]");
        wr(" /ImageMatrix [DPI 0 0 DPI neg 0 HEIGHT]");
        wr(" /DataSource currentfile /ASCII85Decode filter << >> /DCTDecode filter");
        wr(">>");
        wr("image");
    

I'm converting Bitmap to GrayScale image:

public Bitmap toGrayscale(Bitmap bmpOriginal) {
        int width, height;
        height = bmpOriginal.getHeight();
        width = bmpOriginal.getWidth();
        Bitmap bmpGrayscale = Bitmap.createBitmap(width, height,
                Bitmap.Config.ARGB_8888);
        Canvas c = new Canvas(bmpGrayscale);
        Paint paint = new Paint();
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
        paint.setColorFilter(f);
        c.drawBitmap(bmpOriginal, 0, 0, paint);
        return bmpGrayscale;
    }

Getting Offending command: O8f3g-d

This error text is part of the bitmap outputstram.

enter image description here

I visualized ps data PostScript Viewer, But the image getting cropped. If I use /DeviceGray /Decode [0 1 0 1 0 1] then image is not cropped. So can't understand where is the problem.

enter image description here

0

There are 0 answers