Article View: adobe.postscript.programming
Article #1173Re: DCTEncode filter
From: Gernot Hoffmann
Date: Sat, 08 Mar 2003 13:38
Date: Sat, 08 Mar 2003 13:38
149 lines
4889 bytes
4889 bytes
Miklos,
I have solved the problem (including the A-channel, this is not in
the example but simple).
The only remaining problem is:
I cannot define a File "Imi" which is in memory instead of disk.
The program executes:
Read BMP-24 "src". Decode header. Read raw RGB data.
Swap BGR . Write to file "Imi". Read "Imi" and show.
Everything OK. even for huge images.
Best regards --Gernot
The original text was nicely formatted, appears here garbled.
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 1000 1000
%%Creator: Gernot Hoffmann
%%Title: BmpImage01
%%CreationDate: March 07,2003
%%DocumentNeededResources: font Helvetica
%%EndComments
% Read, store and show a named BMP-24 RGB image
/mm {2.834646 mul} def
/ReadHead
{/buf 54 string def
/bmp true def
% Read 54 header bytes 0..53
Src buf readstring pop
% Code (BM)
/cd1 buf 0 1 getinterval def
/cd2 buf 1 1 getinterval def
cd1 (B) ne { /bmp false def } if
cd2 (M) ne { /bmp false def } if
% File Size (Bytes)
/fsz buf 2 get def
/fsz buf 3 get 256 mul fsz add def
/fsz buf 4 get 256 mul 256 mul fsz add def
/fsz buf 5 get 256 mul 256 mul 256 mul fsz add def
% Image Start (54)
/ims buf 10 get def
/ims ims buf 11 get 256 mul add def
/ims ims buf 12 get 256 mul 256 mul add def
/ims ims buf 13 get 256 mul 256 mul 256 mul add def
% Info Size (40)
/ifs buf 14 get def
/ifs ifs buf 15 get 256 mul add def
/ifs ifs buf 16 get 256 mul 256 mul add def
/ifs ifs buf 17 get 256 mul 256 mul 256 mul add def
% x-Pixel
/xpx buf 18 get def
/xpx xpx buf 19 get 256 mul add def
/xpx xpx buf 20 get 256 mul 256 mul add def
/xpx xpx buf 21 get 256 mul 256 mul 256 mul add def
% y-Pixel
/ypx buf 22 get def
/ypx ypx buf 23 get 256 mul add def
/ypx ypx buf 24 get 256 mul 256 mul add def
/ypx ypx buf 25 get 256 mul 256 mul 256 mul add def
% pages (1,0)
/pg1 buf 26 get def
/pg2 buf 27 get def
pg1 1 ne { /bmp false def } if
pg2 0 ne { /bmp false def } if
% BitperPixel (24,0 )
/bp1 buf 28 get def
/bp2 buf 29 get def
bp1 24 ne { /bmp false def } if
% Uncompressed (0,0)
/cp1 buf 30 get def
/cp2 buf 31 get def
cp1 0 ne { /bmp false def } if
cp2 0 ne { /bmp false def } if
% Bytes per Pixel
/byt bp1 8 idiv def
} def
/ShowHead
{/b10 10 string def
/fh 14 def
/Helvetica findfont fh scalefont setfont
/x1 10 mm def
/x2 60 mm def
/y 200 mm def
/dy fh 1.2 mul def
x1 y moveto (BM code) show x2 y moveto cd1 show cd2 show /y y dy sub def
x1 y moveto (Size/Byte) show x2 y moveto fsz b10 cvs show /y y dy sub def
x1 y moveto (Image Start) show x2 y moveto ims b10 cvs show /y y dy sub def
x1 y moveto (Info Size) show x2 y moveto ifs b10 cvs show /y y dy sub def
x1 y moveto (x-Pixels) show x2 y moveto xpx b10 cvs show /y y dy sub def
x1 y moveto (y-Pixels) show x2 y moveto ypx b10 cvs show /y y dy sub def
x1 y moveto (Page) show x2 y moveto pg1 b10 cvs show ( ) show pg2 b10 cvs show /y y dy sub def
x1 y moveto (Bit per Pix) show x2 y moveto bp1 b10 cvs show ( ) show bp2 b10 cvs show /y y dy sub def
x1 y moveto (Compression) show x2 y moveto cp1 b10 cvs show ( ) show cp2 b10 cvs show /y y dy sub def
} def
/ReadImag
{% Read Src,swap RGB->BGR,write Imi
/row xpx byt mul string def
/bufA 3 string def
/bufB 3 string def
1 1 ypx
{ pop
/k 0 def
Src row readstring pop
1 1 xpx
{ pop
/bufA row k 3 getinterval def
bufB 0 bufA 2 get put
bufB 1 bufA 1 get put
bufB 2 bufA 0 get put
row k bufB putinterval
/k k 3 add def
} for
Imi row writestring
} for
} def
/ShowImag
{ /DeviceRGB setcolorspace
<< /ImageType 1
/Width xpx
/Height ypx
/BitsPerComponent 8
/ImageMatrix [ xpx 0 0 ypx 0 0 ]
/Decode [ 0 1 0 1 0 1]
/DataSource Imi
">>" actually without ""
image
} def
/Src (J:\\WEmma\\WEmma300.bmp) (r) file def
/Imi (Imi) (w+) file def
ReadHead
ShowHead
ReadImag
10 mm 20 mm translate
xpx ypx scale
ShowImag
showpage
Technical Details
Message-ID:
<1de81742.13@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!logbridge.uoregon.edu!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de81742.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10c61a,f51afc5ab2ff2b54 X-Google-Attributes: gid10c61a,public X-Google-ArrivalTime: 2003-03-08 06:07:57 PST From: "Gernot Hoffmann" <hoffmann@fho-emden.de> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!logbridge.uoregon.edu!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.postscript.programming Subject: Re: DCTEncode filter Message-ID: <1de81742.13@WebX.la2eafNXanI> Date: Sat, 8 Mar 2003 05:38:03 -0800 References: <1de81742.-1@WebX.la2eafNXanI> Lines: 158 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit