I try resolve with imagemagik using command line convert (via shell)
convert "G:\myimage.bmp" -rotate 180 -resize 400x250 -density 300x300
"c:\aa.pcl"
      ?  ?? chr(K_ESC) ......
      x_prnfile="g:\clip52\lavori\massimo\arca\AA.pcl"
      TYPE &X_PRNFILE to print
The image break during printing and page eject
may be that type is not able find end of file (26)



2010/3/1 Massimo Belgrano <[email protected]>:
> I need the capability print a bmp inside a harbour application
> who print plc . is a old clipper application
>
> I Have found a routine who Print .PCX To Laserjet, but need BMP
>
>
> I search a conversion BMP2PCX or printing BMP in pcl
> (I need also rotate image)
>
>
> http://www.karland.com/code/clipper/
> function LoadPCX(cFile)
>
>   
> //----------------------------------------------------------------------------
>   // AUTHOR:     Denis A. Sarrazin (Tue 10-11-1994)
>   // PURPOSE:    to load the PCX into a special array
>   // PARAMETERS: cFile <-- the name of the PCX file to load
>   // RETURNS:    array (see list of #define in MINIPCX.CH and format below)
>   // NOTES:      Format of a .PCX header shown below:
>   //
>   //        Byte  Item            Size Description/Comments
>   //        ----  --------------- ----
> -----------------------------------------
>   //        0     Manufacturer      1  Constant Flag  10 = ZSoft .PCX
>   //        1     Version           1  Version information:
>   //                                     0 = Version 2.5
>   //                                     2 = Version 2.8 w/palette information
>   //                                     3 = Version 2.8 w/o palette
> information
>   //                                     5 = Version 3.0
>   //        2     Encoding          1  1 = .PCX run length encoding
>   //        3     Bits per pixel    1  Number of bits/pixel per plane
>   //        4     Window            8  Picture Dimensions
>   //                                     (Xmin, Ymin) - (Xmax - Ymax)
>   //                                     in pixels, inclusive
>   //        12    HRes              2  Horizontal Resolution of creating 
> device
>   //        14    VRes              2  Vertical Resolution of creating device
>   //        16    Colormap         48  Color palette setting, see text
>   //        64    Reserved          1
>   //        65    NPlanes           1  Number of color planes
>   //        66    Bytes per Line    2  Number of bytes per scan line per
>   //                                     color plane (always even for
> .PCX files)
>   //        68    Palette Info      2  How to interpret palette - 1 = 
> color/BW,
>   //                                                              2 = 
> grayscale
>   //        70    Filler           58  blank to fill out 128 byte header
>   //
>   //        IMPORTANT:
>   //          All sizes are measured in BYTES.
>   //          All variables of size 2 are integers.
>   //
>   
> //----------------------------------------------------------------------------
>   local aPCX
>   local cBuffer
>   local hPCX
>   local nRead
>   local nFileLength
>
>   if !file(cFile)
>
>      aPCX := {}
>
>   else
>
>      aPCX        := array(PCX_LENGTH)
>      hPCX        := fopen(cFile)
>      nFileLength := FLEN(hPCX)
>
>      cBuffer := space(HEADER_SIZE)
>      nRead   := fread(hPCX,@cBuffer,HEADER_SIZE)           // load PCX header
>
>      aPCX[ PCX_MANUFACTURER ]   := asc(substr(cBuffer,1,1))
>      aPCX[ PCX_VERSION ]        := asc(substr(cBuffer,2,1))
>      aPCX[ PCX_ENCODING ]       := asc(substr(cBuffer,3,1))
>      aPCX[ PCX_BITS_PER_PIXEL ] := asc(substr(cBuffer,4,1))
>      aPCX[ PCX_WINDOW ]         := {bin2i(substr(cBuffer,5,2)),;
>                                          bin2i(substr(cBuffer,7,2)),;
>                                          bin2i(substr(cBuffer,9,2)),;
>                                          bin2i(substr(cBuffer,11,2))}
>      aPCX[ PCX_HRES ]           := bin2i(substr(cBuffer,13,2))
>      aPCX[ PCX_VRES ]           := bin2i(substr(cBuffer,15,2))
>      aPCX[ PCX_COLORMAP ]       := substr(cbuffer,17,48)
>      aPCX[ PCX_RESERVED ]       := asc(substr(cBuffer,65,1))
>      aPCX[ PCX_NPLANES ]        := asc(substr(cBuffer,66,1))
>      aPCX[ PCX_BYTES_PER_LINE ] := bin2i(substr(cBuffer,67,2))
>      aPCX[ PCX_PALETTE_INFO ]   := bin2i(substr(cBuffer,69,2))
>      aPCX[ PCX_FILLER ]         := substr(cBuffer,71,58)
>
>      cBuffer := space(nFileLength - HEADER_SIZE)
>      nRead   := fread(hPCX,@cBuffer,nFileLength - HEADER_SIZE)
>      if (nRead != (nFileLength - HEADER_SIZE))
>         messaggio("Attenzione  File TROPPO GRANDE","T")
>      endif
>
>      aPCX[ PCX_PIXELS ] := cBuffer
>
>      fclose(hPCX)
>
>   endif
>
> return (aPCX)
>
>
>
> procedure PrintPCX(nRow,nCol,aPCX)
>   
> //----------------------------------------------------------------------------
>   // AUTHOR:     Denis A. Sarrazin (Tue 10-11-1994)
>   // PURPOSE:
>   // PARAMETERS:
>   // RETURNS:
>   // EXAMPLES:
>   
> //----------------------------------------------------------------------------
>   local nNumCol     := aPCX[PCX_WINDOW,3] - aPCX[PCX_WINDOW,1]+1
>   local nTotalBytes := aPCX[PCX_NPLANES] * aPCX[PCX_BYTES_PER_LINE]
>   local nStartCol
>   local cRasterData := ""
>   local nCount
>   local nNumBytes
>   local cByte
>   local nBytePos
>   local nPixel
>   local nDiff
>   nRow      := int(nRow * 300)
>   nCol      := int(nCol * 300)
>   nStartCol := nCol
>   //   X_graph=""
>   if SetPrinter()  // set the proper codes depending on type of printer
>      //  PrnGrSet( nRow, nCol ) // cGrSet ; PrnGrMove( <r>, <c> )C
>      //    X_graph=X_graph+CHR(K_ESC)+"*t300R" + ;  // raster
> graphics at 300 dpi
>      //        CHR(K_ESC)+"*r1A" +;       // start graphics at current 
> position
>      //                CHR(K_ESC)+"*p"+Cnum(nRow)+"Y"+;
>      //                CHR(K_ESC)+"*p"+Cnum(nStartCol)+"X"
>      ?? chr(K_ESC)+"*t300R"            // raster graphics at 300 dpi
>      ? chr(K_ESC)+"*p"+cNUM(nRow)+"Y"
>      ?? chr(K_ESC)+"*p"+cNUM(nCol)+"X"
>      ?? chr(K_ESC)+"*r1A"              // start graphics at current position
>
>      ? chr(K_ESC)+"*p"+cNUM(nRow)+"Y"
>      ??
>      ?? chr(K_ESC)+"*p"+cNUM(nCol)+"X"
>      ??
>      nBytePos  := 1
>      nNumBytes := 1
>      while (nBytePos < len(aPCX[PCX_PIXELS]))
>         cByte := BYTE2BIN(subst(aPCX[PCX_PIXELS],nBytePos,1))
>         if (left(cByte,2) == "11")
>            nCount := BIN2NUM("00"+substr(cByte,3))
>            nBytePos ++
>            cByte := BYTE2BIN(subst(aPCX[PCX_PIXELS],nBytePos,1))
>         else
>            nCount := 1
>         endif
>         while (nCount > 0)
>            // display all bits in byte (or parts thereof)
>            if ((nCol+8) > (nNumCol+nStartCol - 1))         // chop
> off the excess
>               nDiff := (nCol+8) - (nNumCol+nStartCol - 1) - 1
>               cByte := padr(left(cByte,8 - nDiff),8,"1")   // clear any at end
>            endif
>            cRasterData += chr(XOR(BIN2NUM(cByte),255))     // invert
> '1's and '0's
>            nCol        += 8
>            if (nNumBytes >= nTotalBytes)
>               //          X_graph=X_graph+CHR(K_ESC)+"*p"+cNUM(nRow)+"Y"+;
>               //                     +CHR(K_ESC)+"*p"+cNUM(nStartCol)+"X"+;
>               //
> +CHR(K_ESC)+"*b"+cNUM(LEN(cRasterData))+"W"+cRasterData
>               ? chr(K_ESC)+"*p"+cNUM(nRow)+"Y"
>               ??
>               ?? chr(K_ESC)+"*p"+cNUM(nStartCol)+"X"
>               ??
>               ?? chr(K_ESC)+"*b"+cNUM(len(cRasterData))+"W"+cRasterData
>               ??
>               // PrnGrMove( nRow, nStartCol )
>               // PrnGrLine( cRasterData )
>               cRasterData := ""
>               nNumBytes   := 0
>               nCol        := nStartCol
>               nRow ++
>            endif
>            nNumBytes ++
>            nCount --
>         end
>         nBytePos ++
>      end
>      ? chr(K_ESC)+"*rB"+;              // end raster graphics
>                 chr(K_ESC)+"&a0R"+;    // move to text row 1
>                 chr(K_ESC)+"&a0C"      // move to text column 1
>   endif
>
> return
>
>
>
> --
> Massimo Belgrano
>



-- 
Massimo Belgrano
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to