%!PS

% A .BMP File Format Reporter Gurugram #14
% =========================================
% by  Don Lancaster

%  Copyright c 2002 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552
%  (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com
%  Consulting services available http://www.tinaja.com/info01.html
%  Linking welcome. Reposting expressly forbidden. 

%  All commercial rights and all electronic media rights ~fully~ reserved.
%  Linking usually welcome. Reposting expressly forbidden. Version 1.1 

% Gathers together some non-obvious utilities and routines for
% PostScript Disk access



%  IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program.
%  After obvious location mods, uncomment ONE of the following two lines:

   (C:\\windows\\desktop\\gonzo\\gonzo.ps) run  % use internal gonzo
%  (A:\\gonzo.ps) run  % use external gonzo

%  NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES.

%  GONZO20A Guru Gonzo PostScript power tools (Interim release)
%  Includes gonzo justification and layout utilities.

%  Copyright c 1990, 1996, 2001 by Don Lancaster and Synergetics, Box 809,
%  Thatcher Arizona, 5552 (928) 428-4073  don@tinaja.com  support
%  via http://www.tinaja.com  All commercial rights and all electronic
%  media rights **FULLY** reserved. Reposting is expressly forbidden.

%%%%%%%%%%% links menu directory %%%%%%%%%%%%

% This code locks pdfmark commands out of a PostScript printer.

/pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse

% /surl "start url" marks the beginning of a text sequence to be urled. 
% It also paints the text blue...

/surl {mark /blue cvx 0.33 /setgray cvx     % change text to blue
       /currentpoint cvx                    % remember box start
       /urly /exch cvx /store cvx
       /urlx /exch cvx /store cvx
         ] cvx                              % complete deferred command

       printlist exch 3 index exch put      % stuff into gonzo printlist
       exch 1 add exch                      % increment gonzo list count
} def

% /eurl "end url" unmarks the end of a text sequence and sets up
% the pdfmark needed to define the Acrobat web link. 

/eurl {mark                               % start deferred proc      
       exch                               % position url string
       % /black cvx 0  /setgray cvx         % turn blue marker off 
       % maintextcolor /setrgbcolor  cvx    % reset to main text color???

       /aqua cvx /black cvx
       /makeurl cvx                       % defer call of url builder
        ] cvx                             % complete deferred proc

        printlist exch 3 index exch       % stuff into gonzo printlist
        put exch 1 add exch               % increment gonzo list count      
        } def


% /makeurl generates the pdfmark, receiving a {(urlstring) makeurl}.
% Note that it is not called until formatted printlist time...

/urlover 0.2 def                    % fraction of hot area over bounds

/makeurl { /cururlname exch store          % save the url string
            mark                           % start pdfmark

currentfont /ScaleMatrix get 3 get /fsize exch store  % guess height

  /Rect  [ urlx fsize urlover mul sub      % set box left x
           urly fsize urlover mul sub      % set box left y
           currentpoint
           exch fsize urlover mul add exch
           fsize add
           ]
           /Border [ 0 0 0]   % [0 0 0 ] = none; [0 0 2] = debug 
           /Color [ .7 0 0 ]
           /Action <</Subtype /URI /URI cururlname>>
           /Subtype /Link
           /ANN                            % annotation type
           pdfmark                        % call pdf operators    
} def

% /makeurlx generates the box specific pdfmark, receiving 
% a {(urlstring) makeurl}.
% Note that it is not called until formatted printlist time...


/makeurlx { /cururlnamex exch store        % save the url string
            mark                           % start pdfmark

  /Rect  [ xpos                            % set box left x
           ypos 0.9 sub                    % set box left y
           xpos 2.8 add                    % box right x
           ypos 0.9 sub 2.8 add            % box right y
           ]
           /Border [ 0 0 0]   % [0 0 0 ] = none; [0 0 2] = debug 
           /Color [ .7 0 0 ]
           /Action <</Subtype /URI /URI cururlnamex>>
           /Subtype /Link
           /ANN                            % annotation type
           pdfmark                        % call pdf operators    
} def


/maintextcolor {0 0 0 } def

% text link specific data  -- use dictionary instead below


{

/cubic01 {(http://www.tinaja.com/cubic01.asp) eurl} def
/hack62 {(http://www.tinaja.com/glib/hack62.pdf) eurl} def
/increment {(http://www.tinaja.com/text/bezgen3.html) eurl} def
/interpolate {(http://members.bellatlantic.net/~vze2vrva/design.html) eurl } def

/bezmath {(http://www.tinaja.com/text/bezmath.html) eurl } def

/table {(http://www.tinaja.com/psutils/imtable.psl) eurl } def



} pop

% dictionary method

<<    %zzzzzzzz

%%%% unused links have been commented for gg9a simplicity

/auct01 (http://www.tinaja.com/auct01.asp)
/satadj01 (http://www.tinaja.com/psutils/satadj01.psl)
/noburn01 (http://www.tinaja.com/psutils/noburn01.psl)
/histog01 (http://www.tinaja.com/psutils/histog01.psl)
/shade1 (http://www.tinaja.com/psutils/shade1.psl)
/knockout (http://www.tinaja.com/glib/knockout.bmp)
/magfill1 (http://www.tinaja.com/psutils/magfill1.psl)
/sencri01 (http://www.tinaja.com/images/bargs/sencri01.jpg)
/nikon (http://www.nikon.com)
/swingt01 (http://www.tinaja.com/psutils/swingt01.psl)
/swingtbefore(http://www.tinaja.com/images/bargs/marcon01.bmp)
/swingtafter (http://www.tinaja.com/images/bargs/marconz1.jpg)
/basis (http://www.tinaja.com/glib/basis.pdf)
/cubic01 (http://www.tinaja.com/cubic01.asp)

/nowhit01 (http://www.tinaja.com/psutils/nowhit01.psl)
/knock01 (http://www.tinaja.com/glib/knockout.bmp)
/bmprpt01 (http://www.tinaja.com/psutils/bmprpt01.psl)
/comparebmp (http://www.designer-info.com/Writing/bmp_tiff_jpeg_gif.htm)
/imagimag (http://www.tinaja.com/glib/imagimag.pdf)
/myebays (http://www.tinaja.com/glib/myebays.pdf)
/stepprep (http://www.tinaja.com/glib/stepprep.pdf)
/aafont01 (http://www.tinaja.com/aafont01.asp)
/speedup2 (http://www.tinaja.com/glib/speedup2.pdf)

/guru16 (http://www.tinaja.com/gurgrm16.pdf)

/here1 (http://village.infoweb.ne.jp/~fwhw1257/study/bmpform.htm)
/here2 (http://www.daubnet.com/formats/BMP.html)

/bittype (http://www.tinaja.com/psutils/pdf2bmp.psl)
/photocombine (http://www.tinaja.com/psutils/blender.psl)

/psl (http://www.tinaja.com/psutils/) % dummy temp

/psl1 (http://www.tinaja.com/psutils/pdf2bmp.psl) 
/psl2 (http://www.tinaja.com/psutils/acatdata.psl) 
/psl3 (http://www.tinaja.com/psutils/catwords.psl) 
/psl4 (http://www.tinaja.com/psutils/graburls.psl) 
/psl5 (http://www.tinaja.com/psutils/blender.psl) 
/psl6 (http://www.tinaja.com/psutils/catools1.psl) 
/psl7 (http://www.tinaja.com/psutils/strconv.html) 
/psl8 (http://www.tinaja.com/psutils/bodcat.psl) 
/psl9 (http://www.tinaja.com/psutils/flatvue1.psl) 
/psl10 (http://www.tinaja.com/psutils/fern2img.psl) 
/psl11 (http://www.tinaja.com/psutils/flutools.psl) 
/psl12 (http://www.tinaja.com/psutils/mscal156q.psl) 
/psl13 (http://www.tinaja.com/psutils/weblogu2.psl) 
/psl14 (http://www.tinaja.com/psutils/pfa2pfb.psl) 
/psl15 (http://www.tinaja.com/psutils/pfb2pfa.psl) 
/psl16 (http://www.tinaja.com/glib/psdisk03.psl) 
/psl17 (http://www.tinaja.com/psutils/disktool.psl) 
/psl18 (http://www.tinaja.com/glib/psinscrt.psl) 
/psl19 (http://www.tinaja.com/glib/pssearch.psl) 
/psl20 (http://www.tinaja.com/text/refsum1.html)
/psl21 (http://www.tinaja.com/text/reflog1.html) 
/psl22 (http://www.tinaja.com/psutils/reflog1.psl) 
/psl23 (http://www.tinaja.com/psutils/refsum1.psl) 
/psl24 (http://www.tinaja.com/psutils/searepl.psl) 
/psl25 (http://www.tinaja.com/psutils/weberru2.psl) 
/psl26 (http://www.tinaja.com/psutils/grabsrch.psl) 
/psl27 (http://www.tinaja.com/psutils/grabrefs.psl) 



/magsn01 (http://www.tinaja.com/magsn01.asp)

/gonzoutils (http://www.tinaja.com/post01.asp#gonzo)
/disktool (http://www.tinaja.com/psutils/disktool.ps)

/elesimp (http://www.tinaja.com/glib/elesimp.pdf)
/tn5603 (http://partners.adobe.com/asn/developer/pdfs/tn/TN5603.Filters.pdf)

/fern2img (http://www.tinaja.com/psutils/fern2img.psl)
/fern     (http://www.tinaja.com/psutils/fern2img.pdf)
/oldfern  (http://www.tinaja.com/psutils/fernx1.pdf) 

/acrosdk (http://partners.adobe.com/asn/developer/acrosdk/main.html)


/refman2 (http://partners.adobe.com/asn/developer/pdfs/tn/psrefman.pdf)
/refman3 (http://partners.adobe.com/asn/developer/pdfs/tn/PLRM.pdf)

/s3011 (http://partners.adobe.com/asn/developer/pdfs/tn/PS3010and3011.Supplement.pdf)

/s2011 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2011.supplement.pdf)
/s2012
(http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2012.supplement.pdf)
/s2013
(http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2013.supplement.pdf)
/s2014
(http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2014.supplement.pdf)
/s2015
(http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2015.supplement.pdf)
/s2016
(http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2016.supplement.pdf)


/ghost (http://www.cs.wisc.edu/~ghost/)
/distlang (http://www.tinaja.com/psutils/distlang.html)

/adobepst (http://partners.adobe.com/asn/developer/technotes/)


/maildon (mailto:don@tinaja.com)
/tinaja (http://www.tinaja.com)
/adobe (http://www.adobe.com)
/adobesdk (http://partners.adobe.com/asn/developer/acrosdk/main.html)
/pstrans (http://www.tinaja.com/glib/pstrans.pdf)
/borland (http://www.borland.com/products/downloads/download_cbuilder.html)
/ebay
(http://cgi6.ebay.com/ws/eBayISAPI.dll?ViewSellersOtherItems&userid=abeja&completed=0&sort=2&since=-1&include=0&page=1&rows=100)

/searepl (http://www.tinaja.com/psutils/searepl.psl)




/aasdk (http://www.tinaja.com/plugins/AboutAcrobatSDK.api)
/uncomp (http://www.tinaja.com/plugins/UncompressPDF.api)
/addimage (http://www.tinaja.com/plugins/AddImage.api)
/samplejpg (http://www.tinaja.com/plugins/sample.jpg)
/transparency (http://www.tinaja.com/plugins/Transparency.api)
/threerects (http://www.tinaja.com/plugins/threerects.pdf)
/watermark (http://www.tinaja.com/plugins/Watermark.api)
/verifyurls (http://www.tinaja.com/plugins/VerifyURLS.api)


/flate (http://www.tinaja.com/glib/flatvue.pdf)
/pstrans (http://www.tinaja.com/glib/pstrans.pdf)

/advt01 (http://www.tinaja.com/advt01.asp)
/amlink01 (http://www.tinaja.com/amlink01.asp)
/ng1 (news:///comp.text.pdf)  
/ng2 (news:///comp.lang.postscript)  

/msc++ (http://msdn.microsoft.com/visualc/productinfo/default.asp)

/degub (http://www.tinaja.com/glib/degub.pdf)



/ghostscript (http://www.artifex.com/pressreleases/GS70.htm)


/demox.psl  (http://www.tinaja.com/glib/g9demox.psl)
/demox.pdf  (http://www.tinaja.com/glib/g9demox.pdf)
/demo.pdf   (http://www.tinaja.com/glib/g9demo.pdf)
/flatvue (http://www.tinaja.com/glib/flatvue.psl)

/pdfrefman (http://partners.adobe.com/asn/developer/acrosdk/docs.html)

/psrefman 
(http://partners.adobe.com/asn/developer/technotes/postscript.html)

/pdfmrm
(http://partners.adobe.com/asn/developer/acrosdk/docs.html)

/tipdf
(http://partners.adobe.com/asn/developer/acrosdk/docs.html)

/asdk 
(http://partners.adobe.com/asn/developer/acrosdk)
          
/mtcr (http://support.adobe.com/devsup/devsup.nsf/docs/51864.htm)

/flatvue1 (http://www.tinaja.com/psutils/flatvue1.psl)
/acrob01 (http://www.tinaja.com/acrob01.asp)
/post01 (http://www.tinaja.com/post01.asp)
/info01 (http://www.tinaja.com/info01.asp)
/gurgrm01 (http://www.tinaja.com/gurgrm01.asp)


{

/tilley (http://www.tilleyfoundation.com)
/mnglobal (http://www.mnglobal.com/energy/pg2.htm)
/keely (http://www.keelynet.com)
/evolve (http://www.evolvedtechnology.com)
/hack64 (http://www.tinaja.com/glib/hack64.pdf)
/hackar3 (http://www.tinaja.com/glib/hackar3.pdf)
/resbn58 (http://www.tinaja.com/glib/resbn58.pdf)
/bppt (http://www.batterypoweronline.com)
/muse112 (http://www.tinaja.com/glib/muse112.pdf)
/muse113 (http://www.tinaja.com/glib/muse113.pdf)
/energfun (http://www.tinaja.com/glib/energfun.pdf)
/bashpseu (http://www.tinaja.com/glib/bashpseu.pdf)


/adobe (http://www.adobe.com)
/netscape (http://www.netscape.com)

/gallypsl (http://www.tinaja.com/galley1.psl)
/gallypdf (http://www.tinaja.com/galley1.pdf)

/atn5150 (http://partners.adobe.com/asn/developer/acrosdk/docs/createpdfapi/pdfmarkReference.pdf)

/nutour (http://www.tinaja.com/bargains/nutour02.pdf)
/nutoursource (http://www.tinaja.com/bargains/nutour02.psl) 

/bwhistle (http://www.tinaja.com/glib/bwhistle.pdf) 

/gonzo1 (http://www.tinaja.com/post01.asp#gonzo)


/barg01 (http://www.tinaja.com/barg01.asp)
/weblib01 (http://www.tinaja.com/weblib01.asp)
/gurgrm01 (http://www.tinaja.com/gurgrm01.asp)


/z1 (http://www.tinaja.com/bargains/thumb/albradz2.jpg)
/z2 (http://www.tinaja.com/bargains/sbtesteq.asp)
/z3 (http://www.tinaja.com/images/bargs/albrad02.jpg)

/z4 (http://www.tinaja.com/bargains/thumb/tutenaz2.jpg)
/z5 (http://www.tinaja.com/bargains/sbphone.asp)
/z6 (http://www.tinaja.com/images/bargs/tutena02.jpg)

/sourceme (http://www.tinaja.com/glib/gallery.psl)
/sourceme2 (http://www.tinaja.com/glib/autourl.psl)

} pop



>> {mark exch /eurl cvx ] cvx def} forall





%%%%%%%%%%%%%%%% New colorizer patches %%%%%%%%%%%%%%%%%%
 

 
/boxgrays 0.899 def
/grayshade boxgrays def
/mastergray boxgrays def
/staytint {0.33 setgray} def
/staytint1 {0.25 setgray} def
/showadgrays true def

/red {0 settint} def

 /Zmacro {staytint /ypos ypos 2 add def 72 300 div setlinewidth xpos 
ypos moveto
txtwide 0 rlineto stroke /ypos ypos -2 add def tintoff} def  % hair rule
 
 /amacro {(zy0)  stringmacro /ypos
  ypos ypara add def  0.33 setgray } def             % start drop cap
 /bmacro {(iFy1) stringmacro /ypos
  ypos ypara add def  black} def             % finish drop cap
 

 
% Gonzo character colorizer

/blueon {mark /blue cvx 0.33 /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def

/blueoff {mark /beige cvx 0  /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def

/tinton {mark 0.33 /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def

/tinton1 {mark 0.25 /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def


/tinton1b {mark beige cvx     % try for aqua after url???

 0.25 /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def

/tinton1a {mark /aqua cvx     % try for aqua after url???

 0.25 /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def

/tinton1p {mark /burple cvx     % try for aqua after url???

 0.25 /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def

/tinton1r {mark /red cvx     % try for aqua after url???

 0.25 /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def

/tinton1a {mark /aqua cvx     % try for aqua after url???

 0.25 /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def





/tinton1b {mark /beige cvx     % try for beige after url???

 0.25 /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def





/tintoff {mark 0 /setgray cvx] cvx
        printlist exch 3 index exch put exch 1 add exch} def


%%%%%%%%%%%%%% COMPACT  VERSION OF  COLORIZER II %%%%%%%%%%%%%%%%%%%%%%

/settint {dup /currenttint exch store 5.999 mul dup floor cvi /&cbar
          exch store dup floor sub /&cwt exch store [
{/setgray [ /dup cvx 0.3 &cwt 0.59 mul add /ge cvx
 [1 /exch cvx &cwt 0.59 mul 0.30 add /sub cvx 1 &cwt sub
 0.59 mul 0.11 add /div cvx /dup cvx 1 &cwt sub /mul cvx
 &cwt /add cvx /exch cvx ] cvx [ &cwt 0.59 mul 0.3 add /div
 cvx /dup cvx &cwt /mul cvx 0] cvx /ifelse cvx /setrgbcolor
 cvx] cvx /def cvx}
{/setgray [/dup cvx 0.59 1 &cwt sub 0.3 mul add /ge cvx
 [1 &cwt sub 0.3 mul 0.59 add /sub cvx &cwt 0.3 mul 0.11 add
 /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx /exch cvx
 1 /exch cvx] cvx [1 &cwt sub 0.3 mul 0.59 add /div cvx /dup
 cvx 1 &cwt sub /mul cvx /exch cvx 0] cvx /ifelse cvx
 /setrgbcolor cvx] cvx /def cvx}
{/setgray [/dup cvx 0.59 &cwt 0.11 mul add /ge cvx [&cwt
 0.11 mul 0.59 add /sub cvx 1 &cwt sub 0.11 mul 0.30 add
 /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx 1 /exch
 cvx] cvx [0 /exch cvx &cwt 0.11 mul 0.59 add /div cvx /dup cvx
 &cwt /mul cvx] cvx /ifelse cvx /setrgbcolor cvx] cvx
 /def cvx}
{/setgray [/dup cvx 0.59 1 &cwt sub mul 0.11 add /ge cvx [1 &cwt
 sub 0.59 mul 0.11 add /sub cvx &cwt 0.59 mul 0.30 add /div cvx
 /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx 1] cvx [0 /exch cvx
 1 &cwt sub 0.59 mul 0.11 add /div cvx /dup cvx 1 &cwt sub /mul
 cvx /exch cvx] cvx /ifelse cvx /setrgbcolor cvx] cvx
/def cvx}
{/setgray [/dup cvx 0.11 &cwt 0.30 mul add /ge cvx[&cwt 0.30 mul
 0.11 add /sub cvx 1 &cwt sub 0.30 mul 0.59 add /div cvx /dup
 cvx 1 &cwt sub /mul cvx &cwt /add cvx /exch cvx 1] cvx [ &cwt
 0.30 mul 0.11 add /div cvx /dup cvx &cwt /mul cvx /exch cvx 0
 /exch cvx ] cvx /ifelse cvx /setrgbcolor cvx ] cvx /def cvx}
{/setgray [ /dup cvx 0.30 1 &cwt sub 0.11 mul add /ge cvx[ 1
 /exch cvx 1 &cwt sub 0.11 mul 0.30 add /sub cvx &cwt 0.11 mul
 0.59 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx
 ] cvx [ 1 &cwt sub 0.11 mul 0.30 add /div cvx /dup cvx
 1 &cwt sub /mul cvx 0 /exch cvx] cvx /ifelse cvx /setrgbcolor
 cvx ] cvx /def cvx}

] &cbar get exec exec} bind def

/beige  {0.10 settint} def      % examples of convenience operators
/aqua   {0.52 settint} def
/blue    {0.67 settint} def
/lime     {0.44 settint} def
/burple {0.75 settint} def

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%





/guru { gonzo begin
ps.util.1 begin printerror nuisance begin} def  % 

guru                                           % activate gonzo utilities


50 50 10 setgrid                               % create grid
% 56 61 showgrid  

/setpagefonts {

/cstretch 0.015 def
/sstretch 0.015 def
/font0 /StoneSans-Bold 1.6 gonzofont
/font1 /StoneSans 0.95 gonzofont
/font2 /StoneSans [0.95 0 0.25 0.95 0 0 ] gonzofont
/font4 /StoneSans 0.85 gonzofont
/font3 /StoneSans-Bold 0.85 gonzofont
/font6 /StoneSans-Bold 0.85 gonzofont
/font7 /StoneSans-Bold 1.05 gonzofont   % subheaders

/font8 /StoneSans-Bold [0.65 0 0 0.65 0 0.4] gonzofont

/txtwide 36 store

/yinc 1.2 store
/kern 0.1 store

/pm 1.5 store



aqua 0.33 setgray
font1

black




/amacro { mark /aqua cvx 0.33 /setgray cvx ] cvx
        printlist exch 3 index exch       % stuff into gonzo printlist
        put exch 1 add exch  } def

/bmacro { mark /black cvx ] cvx
        printlist exch 3 index exch       % stuff into gonzo printlist
        put exch 1 add exch  } def

/shiftin {xpos /xposhold exch store /xpos xpos 3 add store} def

/shiftout {/xpos xposhold store} def

/texttop 51 store
/textleft 3 store


/cmacro {aqua 0.25 setgray (znhL7) stringmacro

/xpos xpos 1.7 sub store

/ypos ypos .1 sub def

} def   % left title


/dmacro {black (pL1hz)  stringmacro

/xpos xpos 1.7 add store

/ypos ypos .1 add def} def       % normal text after centered title




/fmacro  % try and fake |
      {mark /gsave cvx 
         /currentpoint cvx
         /moveto cvx
         0.1 /setlinewidth cvx
         0 0.65 /rlineto cvx  /stroke cvx
         /grestore cvx
         ] cvx

       printlist exch 3 index exch put      % stuff into gonzo printlist
       exch 1 add exch                      % increment gonzo list count
} def


} def

setpagefonts

% -2 50.5 (optional header here \274) cl

%% Set document opening conventions. Note DOCVIEW limited.

[/CropBox [0 0 520 620]       % set the wierd size
/PAGES pdfmark 

[ {Catalog} <<
 /ViewerPreferences << /FitWindow true /CenterWindow true >>
 /PageLayout /OneColumn            % continous
 /Pagemode /UseNone                % no thumbs
 /View [/XYZ null null 1 ]         % force 100%
             >>
 /PUT pdfmark



%%%%%%%%%%%%%%%%% START DEMO ART   (not in use) %%%%%%%%%%%%%%%%


%%% Hand patching Info:

%  next available variable is /GS3 
%  transparency gstate is object 2
%  contents stream is object 18  gets  q /GS3 gs (xstuff) Q 
%  be sure to q Q bracket to localize
%  resources stream is object 19    gets  /GS3 2 0 R 


/transoverlay {

   % make a new graphics state
   [ /_objdef {newgsstate} /type /dict /OBJ pdfmark 

   % fill the new overlay graphics state - See PDF manual for details 
   [  {newgsstate}
          <<
            /Type /ExtGState 
            /ca 0.5                % fill transparency is 0.5
            /CA 0.5                % stroke transparency is 0.5
            /BM /Normal 
            /AIS false 
            /OP false 
            /OPM 1 
            /op true 
           >> /PUT

           pdfmark

    % start a Begin Picture graphics overlay subroutine...
    [ /BBox [0 0 1000 1000 ] /_objdef {overlaypix} /BP pdfmark

    % fill the Begin Picture graphics overlay Xobject subroutine...

          0 0.5 1 setrgbcolor     % on the aqua side of blue
          4 4 6 6 rectfill

    % complete the Begin Picture graphics overlay Xobject...
    [ /EP pdfmark

     } def


% Write a two squares program...

  /twosquares { gsave translate
                1 0.5 0 setrgbcolor            % red side of orange
                2 2 6 6 rectfill               % do background opaque box

                [ {overlaypix} /SP pdfmark     % show foreground transparent box

                grestore} def


%  Distill the two squares program. Initially use a BARE Distiller Job
%  Options that has no compression, no embedded fonts, and little else 


save /snap1 exch store
  
%%%  transoverlay                          % create new objects
%%%  14 17.5 twosquares
  
 snap1 restore

%%%%%%%%%%%% END DEMO %%%%%%%

/burpwide 29.5 store

/burplebox3 {save /burp1 exch store

xpos ypos translate -1 .2 mt 3.5 yinc mul .4 add pd burpwide pr 3.5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore

} def

/burplebox2 {save /burp1 exch store

xpos ypos translate -1 .2 mt 2.5 yinc mul .4 add pd burpwide pr 2.5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore

} def


/burplebox2.5 {save /burp1 exch store
xpos ypos translate -1 .2 mt 3 yinc mul .4 add pd burpwide pr 3 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def



/burplebox4 {save /burp1 exch store
xpos ypos translate -1 .2 mt 4.5 yinc mul .4 add pd burpwide pr 4.5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def

/burplebox4.5 {save /burp1 exch store
xpos ypos translate -1 .2 mt 5 yinc mul .4 add pd burpwide pr 5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def



/burplebox5 {save /burp1 exch store
xpos ypos translate -1 .2 mt 5.5 yinc mul .4 add pd burpwide pr 5.5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def

/burplebox6 {save /burp1 exch store
xpos ypos translate -1 .2 mt 6.5 yinc mul .4 add pd burpwide pr 6.5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def


/burplebox7 {save /burp1 exch store
xpos ypos translate -1 .2 mt 7.5 yinc mul .4 add pd burpwide pr 7.5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def



/burplebox7.5 {save /burp1 exch store
xpos ypos translate -1 .2 mt 8 yinc mul .4 add pd burpwide pr 8 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def

/burplebox8 {save /burp1 exch store
xpos ypos translate -1 .2 mt 8.5 yinc mul .4 add pd burpwide pr 8.5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def

/burplebox9 {save /burp1 exch store
xpos ypos translate -1 .2 mt 9.5 yinc mul .4 add pd burpwide pr 9.5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def

/burplebox20 {save /burp1 exch store
xpos ypos translate -1 .2 mt 20.5 yinc mul .4 add pd burpwide pr 20.5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def

/burplebox36 {save /burp1 exch store
xpos ypos translate -1 .2 mt 36.5 yinc mul .4 add pd burpwide pr 36.5 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def

/burplebox41.5 {save /burp1 exch store
xpos ypos translate -1 .2 mt 42 yinc mul .4 add pd burpwide pr 42 yinc mul .4 add pu closepath
0.9 setgray fill burp1 restore
} def




/pagenum 1 store

/startnewpage {
black  beige 0.35 setgray 
21 -2.5 (|3\320|j) pagenum 10 string cvs mergestr (|j\320) mergestr cc
aqua

showpage

%% start next page 

/pagenum pagenum 1 add store


50 50 10 setgrid                               % create grid
setpagefonts

font1
textleft texttop 
} def

/su {surl font6} store
/to {tinton1 font6} store
/tx {tintoff font1} store



/tabs [11 15 pop 23    ] store

aqua 0.33 setgray
font0

20 47.3 0.7 add  1 sub (Exploring the .BMP File Format) cc
% 20 45.3 0.7 add (Search & Replace Utility) cc
black
font2



textleft 43  0.3 add % this one only  need |h below 
(|/aqua |/staytint1 |3Don Lancaster
Synergetics, Box 809, Thatcher, AZ 85552
copyright c2003 as |/surl |6GuruGram|1|/gurgrm01  |/tinton1 |6#14
|/surl http://www.tinaja.com|/tinaja 
|/surl don@tinaja.com|/maildon 
(928) 428-4073
|/aqua |/black 
|a|0T|b|1|khe |/to .BMP|/tx  image standard is used by Windows and elsewhere to represent graphics images in any of several different display and compression options. The .BMP advantages are that each pixel is usually independently available for any alteration or modification. And that repeated use does not normally degrade the image. Because lossy compression is not used.
|h
Its main disadvantage is that file sizes are usually horrendous compared to JPEG, fractal, GIF, or other lossy compression schemes. A comparison of popular image standards can be |/su found here|1|/comparebmp .
|h
I've long been using the .BMP format for my |/su eBay|1|/ebay  and my other |/su phototography|1|/imagimag ,              |/su scanning|1|/myebays , and |/su post processing|1|/stepprep . I firmly believe that\274
|h|6|/shiftin |/staytint1 
All photography, scanning, and all image post-processing should
|/black |/red |/tinton1r always|/tintoff |/tinton1a  be done using .BMP or a similar non-lossy format. 
|h|/staytint1 
Only |/tinton1r after |/tinton1a all post-processing is complete should JPEG or another
compressed distribution format be chosen.
|h |1|/shiftout |/aqua |/black 
Some current examples of my .BMP work now do include the |/su IMAGIMAG.PDF|1|/imagimag  post-processing tutorial, the |/su Bitmap Typewriter|1|/bittype that generates fully anti-aliased small fonts, the |/su Aerial Photo Combiner|1|/photocombine , and similar utilities and tutorials found on our |/su Fonts & Images|1|/aafont01 ,  |/su PostScript|1|/post01 , and on our |/su Acrobat|1|/acrob01  library pages. 
|h
A few projects of current interest involving .BMP files include true view camera swings and tilts for a digital camera, distortion correction, dodging & burning, preventing white punchthrough on knockouts, and emphasis vignetting. Mainly applied to uncompressed RGBX 24-bit color .BMP files. 
|c
The .BMP Format
|d
Two typical discussions of the .BMP format can be found |/su Here|1|/here1  and |/su Here|1|/here2 . In general, a .BMP file consists of a header, an optional color lookup table area, and a pixel data area. Header data values are LSB first. 

)cl

startnewpage

/fudge {/ypos ypos 0.3 sub store} def

/tabs [9 15] store

(Here is how the .BMP header is usually organized.\274
|6|/shiftin |/burplebox41.5 
|/to |600|j-|j01   $00|j-|j$01|1|/tx   |tASCII 2-byte "BM" bitmap identifier.
|h
|/to |602|j-|j05   $02|j-|j$05|1|/tx   |tTotal length of bitmap file in bytes. 
                                       |tFour byte integer, LSB first.
|h
|/to |606|j-|j09   $06|j-|j$09|1|/tx   |tReserved, possibly for image id or revision. 
                                       |tFour byte integer, LSB first.
|h
|/to |610|j-|j13   $0A|j-|j$0D|1|/tx   |tOffset to start of actual pixel data. 
                                       |tFour byte integer, LSB first.
|h
|/to |614|j-|j17   $0A|j-|j$11|1|/tx   |tSize of data header, usually 40 bytes. 
                                       |tFour byte integer, LSB first.
|h
|/to |618|j-|j21   $12|j-|j$15|1|/tx   |tWidth of bitmap in pixels.
                                       |tFour byte integer, LSB first.
|h
|/to |622|j-|j25   $16|j-|j$19|1|/tx   |tHeight of bitmap in pixels.
                                       |tFour byte integer, LSB first.  
|h
|/to |626|j-|j27   $1A|j-|j$1B|1|/tx   |tNumber of color planes. Usually 01
                                       |tTwo byte integer, LSB first. 
|h
|/to |628|j-|j29   $1C|j-|j$1D|1|/tx   |tNumber of bits per pixel. Sets color mode.
                                       |tTwo byte integer, LSB first.                                     
|h
                                       |t         1 - Monochrome
                                       |t         4 - 16 lookup colors
                                       |t         8 - 256 lookup colors
                                       |t       16 - 65,536 lookup colors
                                       |t       24 - 16,777,216 RGB colors
                                       |t       32 - 16,777,216 RGB colors + alpha
|h
|/to |630|j-|j33   $1E|j-|j$21|1|/tx   |tNon-lossy compression mode in use
                                       |tFour byte integer, LSB first.                                     
|h
                                       |t         0 - None
                                       |t         1 - 8-bit run length encoded
                                       |t         1 - 4-bit run length encoded
|h
|/to |634|j-|j37   $22|j-|j$25|1|/tx   |tSize of stored pixel data
                                       |tFour byte integer, LSB first. 
|h
|/to |638|j-|j41   $26|j-|j$29|1|/tx   |tWidth resolution in pixels per meter
                                       |tFour byte integer, LSB first.
|h
|/to |642|j-|j45   $2A|j-|j$2D|1|/tx   |tHeight resolution in pixels per meter
                                       |tFour byte integer, LSB first.
|1|/shiftout |/aqua |/black 
                                                                                                          more\274
) cl

startnewpage

(|6|/shiftin |/burplebox4.5 
|/to |646|j-|j49   $2E|j-|j$31|1|/tx   |tNumber of colors actually used.
                                       |tFour byte integer, LSB first.
|h
|/to |650|j-|j53   $32|j-|j$35|1|/tx   |tNumber of important colors
                                       |tFour byte integer, LSB first.
|1|/shiftout |/aqua |/black 
Color lookup tables follow the header for those lower performance modes in which they are used. These in turn are followed by the actual pixel data in appropriate format.
|h
My main interest lies in the 24-bit uncompressed RGB color mode. In this mode, there are no color lookup tables used. Nor are the "colors available" and "colors used" data fields used. Each pixel consists of an 8-bit blue byte, a green byte, and a red byte in that order. Working from left to right upwards line-by-line |/to starting          |/to at the lower left|/tx . The pixel data starts at the data offset and continues to the end of the .BMP file.
|c
Understanding Line Padding
|d
There is a crucial little |/to line padding|/tx  detail that must be attended to when dealing with actual .BMP bitmap data. The rule is simply\274
|h|6|/shiftin |/red 
|/tinton1r Each new .BMP line must start on an even 32 bit boundary!
|h|1|/shiftout |/aqua |/black 
Because three does not divide into four very well, |/to zero, one, two, or three 00         |/to padding bytes must be added to the end of each .BMP data line|/tx  in the 24-bit uncompressed format. The exact number of padding bits is set by the number of horizontal pixels per line.
|h
Here is some |/su PostScript|1|/post01  code to determine your end-of-line padding needed\274
|6|/shiftin |/burple |/staytint1 |/burplebox2 
/padding hres 3 mul cvi 4 mod       |t|t% find 32-byte block start
[ 0 3 2 1 ] exch get def            |t|t% save as TLU correction
|1|/shiftout |/aqua |/black 
One sneaky way of dealing with padding is to create a line buffer of hres*3 plus padding. Then zero out |/to three|/tx  end characters. Any unneeded padding bytes will later get overwritten by real pixel data.
|/fudge |c
A .BMP Header Reader
|d
As our first .BMP manipulation example, |/su BMPRPT01.PSL|1|/bmprpt01  is a simple bitmap header reader and reporter. It will read a .BMP header and report format, compression, and most key values. The same code forms the essential core for fancier .BMP manipulation routines as it extracts key values and doubles as a version verifier.
|h
To use, bring this file up in a wp or editor, change the filename, and resave |/to as a        |/to standard ASCII textfile|/tx . Then send to distiller. The bitmap header info is then reported both to screen and to your log file.
) cl

startnewpage


(This routine currently uses my full |/su Gonzo Utilities|1|/gonzoutils . If desired, this |/to mergestr|/tx  string merger can be substituted\274
|6|/shiftin |/burple |/staytint1 |/burplebox3 
/mergestr {2 copy length exch length add string dup dup
4 3 roll 4 index length exch putinterval 3 1 roll exch
0 exch putinterval} def 
|1|/shiftout |/aqua |/black 
|c
Preventing White "Punch Through"
|d
Here's a second example of the neat things you can do by using |/su PostScript|1|/post01  modification of .BMP bitmap images: There's a deadly little trap if you knockout an image to a white outline and then tow it over a |/su new background|1|/knock01 . If there are any inadvertent true white pixels |/tinton1r |6inside|1|/tintoff  of your image, the new background will "punch through" with disastrous results. And hand patching can be a real pain. Especially if you miss a crucial highlight pixel or two.
|h
This |/su NOWHIT01.PSL|1|/nowhit01  routine scans a RGB bitmap, and replaces all $FF $FF $FF (|jor 255 255 255|j) white pixels with "almost white" $FE FE FE pixels. You can also use it to make |/to any|/tx  color into the white needed for Paint transparency.
|h
To use this utility, bring it up in a suitable word processor or editor, change the old and new .BMP filenames, resave, and send to Distiller. The code first checks the header to make sure you really have a 24-bit uncompressed .BMP file. It then copies the header and scans the rest of the triads a horizontal line at a time. Non-white triads are copied, while any true white ones will get substituted with a very light "ivory".
|h
While you could read and write every 3-byte RGB triad to disk, this might need millions of separate disk reads or writes. Instead, it is |/su much faster|1|/speedup2  to use a pair of         |/to buffer|/tx  strings and work a line at a time. Here is how you might define these strings while handling padding at the same time\274 
|6|/shiftin |/burple |/staytint1 |/burplebox6 
/linestring hres 3 mul padding add string store   
/targetstring hres 3 mul padding add string store 
|h
targetstring dup length 1 sub 0 put  
targetstring dup length 2 sub 0 put   
targetstring dup length 3 sub 0 put
|1|/shiftout |/aqua |/black 
|h
|c
Swings & Tilts for Your Digital Camera!
|d
Very impressive things can happen if you grab each .BMP image line and then selectively move each pixel to the right or left by just the right amount. This lets you do traditional view camera swings and tilts. Views can easily be changed to "architectural perspective" where all vertical lines in the real world end up vertical in your image.
) cl

startnewpage


(Detailed swing and tilt instructions and examples appear in |/su GuruGram #16|1|/swingt01 . The basic routine is |/su SWINGT01.PSL|1|/swingt01 , helped along by these |/su before|1|/swingtbefore  and |/su after|1|/swingtafter  files. Images are grabbed one line at a time. The pixels on each line are then suitably moved and stretched to get the desired effect. The key secret is to use the |/su Cubic|/cubic01      |/su Spline|1|/cubic01  Basis Functions of |/su GuruGram #4|1|/basis  to interpolate between your pixels at the highest possibly quality.
|h
|c
"Dual Mode" Photography
|d
Multiple exposures can often greatly improve a final image. For instance, the contrast can be dramatically increased on a label or nameplate or whatever. A sub image is then knocked out to white and pasted over the original. Or stock feet or handles or better knobs or oscilloscope screens can be added. With care, the process can be made seamless.
|h
I've found that using |/to both|/tx  a camera and a scanner on the same image can reap huge benefits. Ferinstance, the |/su Nikon CoolPix5000|1|/nikon  takes outstanding photos, but it tends to burn out meter faces on autoexposure flash. So, you take your main photo with the Nikon and then high resolution scan the meter face. Our swings and tilts get used |/to backwards|/tx  to convert a rectangular meter face scan into the proper trapezoidal perspective shape for pastein.
|h
A subtle advantage of this technique is that the "text plane" of a scanner is always properly aligned for |/to all|/tx  the sharpest possible lettering. When the subject is on an angle, the camera can only truly focus on a small portion of the lettering. Which is what the lens plane "tilt" feature of a view camera was all about.
|h
As |/su this example|1|/sencri01  shows us, you first crop the meter face to the correct left and right edges. Then you scale the left edge to get its size right. Then you rotate the face 90 degrees and offset the original right edge to get the proper amount of climb. You then reduce the gain of the right edge to get the proper amount of scaling. Finally, you rotate back, knockout to white and paste the face on top of the original photo. With practice, this takes only a few minutes. 
|h
|c
A Magic Backgrounder
|d
There's lots of other tricks you can do by examining each RGB pixel and then selectively modifying them. |/su MAGFILL1.PSL|1|/magfill1  is a |/su PostScript-as-Language|1|/post01  routine of mine that replaces a white background with a "magic" background consisting of three or more random colors. The colors are often closely spaced to give a "rich" or "interesting" appearance. They are similar to |/su KNOCKOUT.BMP|1|/knockout .
|h
The "magic" part comes in that |/to random dots like these virtually eliminate any      |/to JPEG edge artifacts!|/tx . Giving you much better online image quality. |/su MAGFILL1.PSL|1|/magfill1  is also much faster than hand patching |/su KNOCKOUT.BMP|1|/knockout , since you simply knockout to white. In theory, your JPG filelengths will get somewhat larger, but this does not seem to be significant.
) cl

startnewpage

(Here is how I normally use |/su MAGFILL1.PSL|1|/magfill1 : I first grab an image using a digital camera or scanner. The image is scaled to a large convenient .BMP worksize and cropped. About six megs seems to be best for eBay stuff. The image then may get distorted into "architect's perspective" using our the |/su SWINGT01.PSL|1|/swingt01  routines.
|h
At this point, the image may still contain some true white pixels. We get rid of these using |/su NOWHIT01.PSL|1|/nowhit01  to eliminate any future "punch thru" problems. It is important to run |/su NOWHIT01.PSL|1|/nowhit01  |/to after|/tx  all swings and tilts, resizing, or other early adjustments, to make sure no inadvertent true whites get added.
|h
The image is then traced to a white outline and then knocked out by a simple Paint exterior fill. |/su MAGFILL1.PSL|1|/magfill1  is brought up in a wp or editor and its filenames are changed. It is resaved as an |/to ordinary ASCII textfile|/tx  and sent to |/su Distiller|1|/adobe . The magic background appears in the chosen image in a few seconds. A catalog of favorite magic backgrounds is easily included. 
|h
|c
For Further Help
|d
Some additional bitmap examples include our |/su histogram analyzer|1|/histog01 , a standalone     |/su shading corrector|1|/shade1 , a standalone |/su saturation adjuster|1|/satadj01 , and my not-quite-ready         |/su burnout reducer|1|/noburn01 .
|h
Consulting assistance on any and all of these topics can be found through our           |/su InfoPack|1|/info01  service. Related |/su Guru's Lair|1|/tinaja  library pages include our |/su GuruGram|1|/gurgrm01 ,               |/su PostScript|1|/post01 , |/su Acrobat|1|/acrob01 , |/su Auction Help|1|/auct01  and |/su Fonts & Images|1|/aafont01  selections.
|h 

Additional |/surl |6GuruGrams|1|/gurgrm01  await your ongoing support as a |/surl |6Synergetics Partner|1|/advt01 .

) cl

startnewpage


%%%%%%%%%%%%%%%%%%%%

% EOF