×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to implement raster scaling in PCL?

How to implement raster scaling in PCL?

How to implement raster scaling in PCL?

(OP)
Hi all,
I would like to extract BMP image from PCL and have a success with 24 bit BMP, but the extraction was incorrect in case the PCL file includes two PCL commands "Destination Raster Height/Width" (Esc * t # V and Esc * t # H). According to HP document, i know we need to implement raster scaling at here, but i don't clearly understand the specification.
Here is the extraction of my PCL file

[ ESC * p 666 X ]
[ ESC * p 74 Y ]  
[ ESC * t 70 h ]      Raster Graphics Width : 70
[ ESC * t 73 V ]      Raster Graphics Height : 73
[ ESC * r 29 s ]      Raster Graphics Width : 29
[ ESC * r 30 T ]      Raster Graphics Height : 30
[ ESC * r 3 A ]       Start Raster Graphics : Scaled at current X position
[ ESC * b 3 M ]       Set Raster Compression :
.....

Please help me the basic ideas to archive this.
Thanks in advance.
Tuan Nguyen.

RE: How to implement raster scaling in PCL?

Several comments about your PCL:

(a) <Esc>*t70h<Esc>*t73V is not valid PCL.
Use either:
    <Esc>*t70H<Esc>*t73V
or:
    <Esc>*t70h73V

(b) <Esc>*r29s<Esc>*r30T is not valid PCL.
Use either:
    <Esc>*r29S<Esc>*r30T
or:
    <Esc>*r29s30T


i.e. something like:

CODE

<Esc>*p666X       Cursor Position Horizontal (666 PCL units)
<Esc>*p74Y        Cursor Position Vertical   (74 PCL units)
<Esc>*t70h        Raster Width: Destination (70 decipoints)
       73V        Raster Height: Destination (73 decipoints)
<Esc>*r29s        Raster Width: Source (29 pixels)
       30T        Raster Height: Source (30 raster rows)
<Esc>*r3A         Start Raster Graphics: Scale Mode at CAP
<Esc>*b3M         Set Compression Mode: Delta Row

Note that the "Raster Width: Destination" and "Raster Height: Destination" sequences are not supported on all LaserJet printers.


I'm not quite sure what your question is - it seems that you are attempting to interpret existing PCL, with the intention (perhaps) of displaying the result on a screen?

RE: How to implement raster scaling in PCL?

(OP)
You're correct me at command <Esc>*t70h, it's just tying error. I'm trying to convert PCL to PDF, anytime i meet the pair "Start Raster" and "End Raster", i will try to extract raster data and write it to BMP file. Here is the link of a simple PCL that i'm working on:

http://www.mediafire.com/?8fg7k5n4m43k6e9

These commands was generated by "HP Color Larsejet5", very standard PCL 5c.
















 

RE: How to implement raster scaling in PCL?

I don't think that converting a PCL raster image back to a bitmap is all that straightforward.

You'd have to take into account the different methods of defining palettes, compression methods, etc.

Jim Asman (if he responds to this thread) will be able to explain this much more authoritatively.

If it helps, an analysis of your PCL file is shown below.

Note:

- Some sequences (e.g. <Esc>*o#Wxx-xx = Driver Configuration) are not well documented.

- Some sequences (e.g. <Esc>*v#Wxx-xx = Configure Image Data) are only supported on colour or greyscale printers.

- The Esc*t#H (Raster Width: Destination) and <Esc>*t#V (Raster Height: Destination) sequences are not supported on all LaserJet printers.

CODE

*** Prn Analysis ***:

Date/Time:  2011-08-05 10:36:54
File:       E:\Forums\Tek-Tips\color4.pcl
Size:       841 bytes
Report:     191 rows (excluding header and trailer lines)

Offset       Type                   Sequence          Description
-----------  ---------------------  ----------------  ----------------------------------------------------

0000000000   PCL Parameterised      <Esc>%-12345X     Universal Exit Language (UEL)
             Comment                                  Switch language to PJL
0000000009   PJL Command            @PJL COMMENT       HP Color LaserJet 5/5MVersion 0.56[0a]
0000000057   PJL Command            @PJL SET           RESOLUTION=300[0a]
0000000081   PJL Command            @PJL ENTER         LANGUAGE=PCL[0a]
             Comment                                  Switch language to PCL
0000000105   Data                                     [0d]
0000000106   PCL Simple             <Esc>E            Printer Reset
0000000108   PCL Parameterised      <Esc>*t300R       Raster Graphics Resolution (300 dots per inch)
0000000115   PCL Parameterised      <Esc>&u300D       Unit-of-Measure (300 PCL units per inch)
0000000122   PCL Parameterised      <Esc>*r0F         Raster Graphics Presentation: Logical
0000000127   PCL Parameterised      <Esc>&l0o         Orientation: Portrait
0000000132                                 1E         Top Margin (1 lines)
0000000134   PCL Parameterised      <Esc>&l1H         Paper Source: id 1 is Printer Dependent
0000000139   PCL Parameterised      <Esc>&l2a         Page Size: Letter
0000000144                                 8c         Vertical Motion Index (8/48 inches)
0000000146                                 1E         Top Margin (1 lines)
0000000148   PCL Parameterised      <Esc>*p0x         Cursor Position Horizontal (0 PCL units)
0000000153                                 0Y         Cursor Position Vertical   (0 PCL units)
0000000155   PCL Parameterised      <Esc>*c0t         Set Picture Frame Anchor Point
0000000160                                 5760x      Picture Frame Size Width  (5760 decipoints)
0000000165                                 7630Y      Picture Frame Size Height (7630 decipoints)
0000000170   PCL Parameterised      <Esc>&l1X         Number of Copies (1)
0000000175   PCL Parameterised      <Esc>&l0M         Media Type: Plain Paper
0000000180   PCL Parameterised      <Esc>*b0M         Set Compression Mode: Unencoded
0000000185   Data                                     [0d]
0000000186   PCL Parameterised      <Esc>*v1N         Source Transparency Mode: Opaque
0000000191   PCL Parameterised      <Esc>*v1O         Pattern Transparency Mode: Opaque
0000000196   PCL Parameterised      <Esc>*l184O       Logical Operation (ROP3): 184: TSDTxax
0000000203   PCL Parameterised      <Esc>*v6W         Configure Image Data (data length = 6)
0000000208   PCL Binary             [ 6 bytes ]       [ 00 03 08 08 08 08 ]
0000000214   PCL Parameterised      <Esc>*v0a         Colour Component 1 (primary value = 0)
0000000219                                 0b         Colour Component 2 (primary value = 0)
0000000221                                 0c         Colour Component 3 (primary value = 0)
0000000223                                 7i         Assign Colour Index (index = 7)
0000000225                                 255a       Colour Component 1 (primary value = 255)
0000000229                                 255b       Colour Component 2 (primary value = 255)
0000000233                                 255c       Colour Component 3 (primary value = 255)
0000000237                                 0I         Assign Colour Index (index = 0)
0000000239   PCL Parameterised      <Esc>*o3W         Driver Configuration (data length = 3)
0000000244   PCL Binary             [ 3 bytes ]       [ 06 04 00 ]
0000000247   PCL Parameterised      <Esc>*v0N         Source Transparency Mode: Transparent
0000000252   PCL Parameterised      <Esc>&p5i         Palette Control ID (identifier = 5)
0000000257                                 6c         Palette Control: Copy Palette
0000000259                                 5S         Select Palette (identifier = 5)
0000000261   PCL Parameterised      <Esc>*v6W         Configure Image Data (data length = 6)
0000000266   PCL Binary             [ 6 bytes ]       [ 00 01 08 08 08 08 ]
0000000272   Data                                     [0d]
0000000273   PCL Parameterised      <Esc>*p0Y         Cursor Position Vertical   (0 PCL units)
0000000278   PCL Parameterised      <Esc>*t0J         Render Algorithm: Continuous Tone
0000000283   PCL Parameterised      <Esc>*o3W         Driver Configuration (data length = 3)
0000000288   PCL Binary             [ 3 bytes ]       [ 06 04 03 ]
0000000291   PCL Parameterised      <Esc>*v0N         Source Transparency Mode: Transparent
0000000296   PCL Parameterised      <Esc>&p5S         Select Palette (identifier = 5)
0000000301   PCL Parameterised      <Esc>*v255a       Colour Component 1 (primary value = 255)
0000000308                                 255b       Colour Component 2 (primary value = 255)
0000000312                                 255c       Colour Component 3 (primary value = 255)
0000000316                                 0I         Assign Colour Index (index = 0)
0000000318   PCL Parameterised      <Esc>*v0a         Colour Component 1 (primary value = 0)
0000000323                                 0b         Colour Component 2 (primary value = 0)
0000000325                                 0c         Colour Component 3 (primary value = 0)
0000000327                                 1I         Assign Colour Index (index = 1)
0000000329   PCL Parameterised      <Esc>*v0a         Colour Component 1 (primary value = 0)
0000000334                                 0b         Colour Component 2 (primary value = 0)
0000000336                                 0c         Colour Component 3 (primary value = 0)
0000000338                                 1I         Assign Colour Index (index = 1)
0000000340   PCL Parameterised      <Esc>*v0t         Select Current Pattern: Solid Black
0000000345                                 1S         Foreground Colour (index = 1)
0000000347   PCL Parameterised      <Esc>*v0a         Colour Component 1 (primary value = 0)
0000000352                                 0b         Colour Component 2 (primary value = 0)
0000000354                                 0c         Colour Component 3 (primary value = 0)
0000000356                                 1I         Assign Colour Index (index = 1)
0000000358   PCL Parameterised      <Esc>*l240O       Logical Operation (ROP3): 240: T
0000000365   PCL Parameterised      <Esc>*v0N         Source Transparency Mode: Transparent
0000000370   PCL Parameterised      <Esc>*v1O         Pattern Transparency Mode: Opaque
0000000375   PCL Parameterised      <Esc>&p9i         Palette Control ID (identifier = 9)
0000000380                                 6c         Palette Control: Copy Palette
0000000382                                 9S         Select Palette (identifier = 9)
0000000384   PCL Parameterised      <Esc>*v6W         Configure Image Data (data length = 6)
0000000389   PCL Binary             [ 6 bytes ]       [ 00 01 01 08 08 08 ]
0000000395   PCL Parameterised      <Esc>&p8i         Palette Control ID (identifier = 8)
0000000400                                 6c         Palette Control: Copy Palette
0000000402                                 8S         Select Palette (identifier = 8)
0000000404   PCL Parameterised      <Esc>*v6W         Configure Image Data (data length = 6)
0000000409   PCL Binary             [ 6 bytes ]       [ 00 01 04 08 08 08 ]
0000000415   PCL Parameterised      <Esc>&p7i         Palette Control ID (identifier = 7)
0000000420                                 6c         Palette Control: Copy Palette
0000000422                                 7S         Select Palette (identifier = 7)
0000000424   PCL Parameterised      <Esc>*v6W         Configure Image Data (data length = 6)
0000000429   PCL Binary             [ 6 bytes ]       [ 00 01 08 08 08 08 ]
0000000435   PCL Parameterised      <Esc>&p6i         Palette Control ID (identifier = 6)
0000000440                                 6c         Palette Control: Copy Palette
0000000442                                 6S         Select Palette (identifier = 6)
0000000444   PCL Parameterised      <Esc>*v6W         Configure Image Data (data length = 6)
0000000449   PCL Binary             [ 6 bytes ]       [ 00 01 08 08 08 08 ]
0000000455   PCL Parameterised      <Esc>&p9S         Select Palette (identifier = 9)
0000000460   PCL Parameterised      <Esc>*t15J        Render Algorithm: Continuous Tone Smooth
0000000466   PCL Parameterised      <Esc>*o3W         Driver Configuration (data length = 3)
0000000471   PCL Binary             [ 3 bytes ]       [ 06 04 00 ]
0000000474   PCL Parameterised      <Esc>*l252O       Logical Operation (ROP3): 252: TSo
0000000481   PCL Parameterised      <Esc>*p615X       Cursor Position Horizontal (615 PCL units)
0000000488   PCL Parameterised      <Esc>*p74Y        Cursor Position Vertical   (74 PCL units)
0000000494   PCL Parameterised      <Esc>*v255a       Colour Component 1 (primary value = 255)
0000000501                                 255b       Colour Component 2 (primary value = 255)
0000000505                                 255c       Colour Component 3 (primary value = 255)
0000000509                                 0I         Assign Colour Index (index = 0)
0000000511   PCL Parameterised      <Esc>*v0a         Colour Component 1 (primary value = 0)
0000000516                                 0b         Colour Component 2 (primary value = 0)
0000000518                                 0c         Colour Component 3 (primary value = 0)
0000000520                                 1I         Assign Colour Index (index = 1)
0000000522   PCL Parameterised      <Esc>*v0a         Colour Component 1 (primary value = 0)
0000000527                                 0b         Colour Component 2 (primary value = 0)
0000000529                                 0c         Colour Component 3 (primary value = 0)
0000000531                                 1I         Assign Colour Index (index = 1)
0000000533   PCL Parameterised      <Esc>*v0t         Select Current Pattern: Solid Black
0000000538                                 1S         Foreground Colour (index = 1)
0000000540   PCL Parameterised      <Esc>*v0a         Colour Component 1 (primary value = 0)
0000000545                                 0b         Colour Component 2 (primary value = 0)
0000000547                                 0c         Colour Component 3 (primary value = 0)
0000000549                                 1I         Assign Colour Index (index = 1)
0000000551   PCL Parameterised      <Esc>*t61h        Raster Width: Destination (61 decipoints)
0000000557                                 73V        Raster Height: Destination (73 decipoints)
0000000560   PCL Parameterised      <Esc>*r25s        Raster Width: Source (25 pixels)
0000000566                                 30T        Raster Height: Source (30 raster rows)
0000000569   PCL Parameterised      <Esc>*r3A         Start Raster Graphics: Scale Mode at CAP
0000000574   PCL Parameterised      <Esc>*b4W         Transfer Raster Data By Row/Block (data length = 4)
0000000579   PCL Binary             [ 4 bytes ]       [ ff ff c0 00 ]
0000000583   PCL Parameterised      <Esc>*b3M         Set Compression Mode: Delta Row
0000000588   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000593   PCL Binary             [ 2 bytes ]       [ 02 f8 ]
0000000595   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000600   PCL Binary             [ 2 bytes ]       [ 02 fc ]
0000000602   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000607   PCL Binary             [ 2 bytes ]       [ 02 fe ]
0000000609   PCL Parameterised      <Esc>*b0W         Transfer Raster Data By Row/Block (data length = 0)
0000000614   PCL Parameterised      <Esc>*b0M         Set Compression Mode: Unencoded
0000000619   PCL Parameterised      <Esc>*b4W         Transfer Raster Data By Row/Block (data length = 4)
0000000624   PCL Binary             [ 4 bytes ]       [ fc 00 ff 00 ]
0000000628   PCL Parameterised      <Esc>*b3M         Set Compression Mode: Delta Row
0000000633   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000638   PCL Binary             [ 2 bytes ]       [ 02 7f ]
0000000640   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000645   PCL Binary             [ 2 bytes ]       [ 02 3f ]
0000000647   PCL Parameterised      <Esc>*b0W         Transfer Raster Data By Row/Block (data length = 0)
0000000652   PCL Parameterised      <Esc>*b0W         Transfer Raster Data By Row/Block (data length = 0)
0000000657   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000662   PCL Binary             [ 2 bytes ]       [ 02 7e ]
0000000664   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000669   PCL Binary             [ 2 bytes ]       [ 02 fe ]
0000000671   PCL Parameterised      <Esc>*b0M         Set Compression Mode: Unencoded
0000000676   PCL Parameterised      <Esc>*b4W         Transfer Raster Data By Row/Block (data length = 4)
0000000681   PCL Binary             [ 4 bytes ]       [ ff ff fc 00 ]
0000000685   PCL Parameterised      <Esc>*b3M         Set Compression Mode: Delta Row
0000000690   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000695   PCL Binary             [ 2 bytes ]       [ 02 f8 ]
0000000697   PCL Parameterised      <Esc>*b0W         Transfer Raster Data By Row/Block (data length = 0)
0000000702   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000707   PCL Binary             [ 2 bytes ]       [ 02 fc ]
0000000709   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000714   PCL Binary             [ 2 bytes ]       [ 02 fe ]
0000000716   PCL Parameterised      <Esc>*b0M         Set Compression Mode: Unencoded
0000000721   PCL Parameterised      <Esc>*b4W         Transfer Raster Data By Row/Block (data length = 4)
0000000726   PCL Binary             [ 4 bytes ]       [ fc 00 7f 00 ]
0000000730   PCL Parameterised      <Esc>*b3M         Set Compression Mode: Delta Row
0000000735   PCL Parameterised      <Esc>*b3W         Transfer Raster Data By Row/Block (data length = 3)
0000000740   PCL Binary             [ 3 bytes ]       [ 22 3f 80 ]
0000000743   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000748   PCL Binary             [ 2 bytes ]       [ 02 1f ]
0000000750   PCL Parameterised      <Esc>*b0W         Transfer Raster Data By Row/Block (data length = 0)
0000000755   PCL Parameterised      <Esc>*b0W         Transfer Raster Data By Row/Block (data length = 0)
0000000760   PCL Parameterised      <Esc>*b0W         Transfer Raster Data By Row/Block (data length = 0)
0000000765   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000770   PCL Binary             [ 2 bytes ]       [ 02 3f ]
0000000772   PCL Parameterised      <Esc>*b3W         Transfer Raster Data By Row/Block (data length = 3)
0000000777   PCL Binary             [ 3 bytes ]       [ 22 7f 00 ]
0000000780   PCL Parameterised      <Esc>*b0M         Set Compression Mode: Unencoded
0000000785   PCL Parameterised      <Esc>*b4W         Transfer Raster Data By Row/Block (data length = 4)
0000000790   PCL Binary             [ 4 bytes ]       [ ff ff ff 00 ]
0000000794   PCL Parameterised      <Esc>*b3M         Set Compression Mode: Delta Row
0000000799   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000804   PCL Binary             [ 2 bytes ]       [ 02 fe ]
0000000806   PCL Parameterised      <Esc>*b0W         Transfer Raster Data By Row/Block (data length = 0)
0000000811   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000816   PCL Binary             [ 2 bytes ]       [ 02 f8 ]
0000000818   PCL Parameterised      <Esc>*b2W         Transfer Raster Data By Row/Block (data length = 2)
0000000823   PCL Binary             [ 2 bytes ]       [ 02 e0 ]
0000000825   PCL Parameterised      <Esc>*rC          End Raster Graphics
0000000829   Form Feed                                [0c]
0000000830   PCL Simple             <Esc>E            Printer Reset
0000000832   PCL Parameterised      <Esc>%-12345X     Universal Exit Language (UEL)
             Comment                                  Switch language to PJL

*** End of Report ***
  

RE: How to implement raster scaling in PCL?

(OP)
Thanks for your help.

Actually, i successfully extract raster data with PCL(s) without having raster scaling command (The Esc*t#H and <Esc>*t#V ). Also, i did a lot of works on color palette, compression , CID command, and these functions are being worked well. Just don't know how to implement raster scaling algorithm (not well documented). Tool PCLReader have ability to properly render the attached file.

Tuan Nguyen.

RE: How to implement raster scaling in PCL?

The Esc*t#H (Raster Width: Destination) and <Esc>*t#V (Raster Height: Destination) sequences use values (with up to 4 decimal places, I think) in units of decipoints.

A point is generally considered these days to be 1/72 inch, so a decipoint is 1/720 inch.

So a destination width of 360 decipoints would equate to a target width of 0.5 inch on the printed paper, and the printer (assuming that it supports these sequences) should scale the source raster width (expressed in units of source pixels) up (or perhaps down) as required, bearing in mind the current specified raster resolution.

I don't think that any of the publicly-available HP documentation defines the algorithm used for this 'Arbitrary Scaling' process.

It is certainly going to be more intelligent than just replicating pixels (as happens with simple 'Resolution Scaling') to avoid 'jaggies', and to maintain colour/greyscale rendering.


... and you have to also consider the (usually down-) scaling you need to apply to your on-screen display/view of the printed page, to fit that into the window/screen dimensions.

RE: How to implement raster scaling in PCL?

(OP)
Thanks you for your help, i'm too busy with other tasks recently, when i come back to this project and have any solution, will be share with you.

Cheers,
Tuan.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close