On Saturday, October 01, 2005, at 10:38AM, Henry Lai <email@hidden> wrote:
> Appreciate your help. Maybe I didn't mention my questions very
> clearly. Let me show you my issue.
>
> The printer is a PCL printer which owns several printer resolution,
> so I need to send some commands which like
>
> Set Cursor Horizontial Position(PCL Units) Esc*p#X
> Set Cursor Vertical Position(PCL Units) Esc*p#Y
> (#means left-top PCL UNIT coordinate of the image, not page )
> Raster Height Esc*r#T
> Raster Width Esc*r#S
> (# means the dots printer will output)
>
> and raster data. Becuse that, I have to know the image size(inch),
> then I can tell the printer the amount of Width/Height dots by
> multipling the printer DPI and image width/height(inch) .
>
> For example, I open a BMP image with Preview which will show me the
> information:
> image DPI:72
> pixels: 62 X 84
> size: 0.86 X 1.17 inch
> RGB
> And my printer DPI is 508(DPI), the Raster Width is 437(0.86X508)
> and Height is 594(1.17X508). So I will send Esc*r 594T and Esc*r437S
> to printer. So, in the printer driver, my question are:
> 1. How can I get the image size, pixels and DPI(not printer DPI)?
> Because they can make me calculate the Raster H/W.
You have a fundamental misunderstanding of what a printer driver is going to get. Your PPD is going to indicate page sizes your printer supports, and the user, through Page Setup, is going to select one, for example Letter (8.5 x 11 inches). When the user prints the 62 x 84 pixel bmp from your example, the application (Preview) is going to position that bmp onto a Letter-sized page, such that the rasters you get in your driver (after passing through cpdftoraster) are going to be a full Letter-sized page (minus margins). Lots of white space with the bmp scaled and positioned somewhere on the page.
> 2. How can I get the correct raster data which matchs the printer's
> resolution? In other word, let cgpdftoraster to generate the raster
> data I needed.
By the time you get the rasters, they will be at printer resolution. If your printer has multiple resolutions, the user will have the opportunity to select the desired resolution if you make the resolution selectable in the PPD.
> 3. In order to set cursor position, how to get the left-top
> coordinate(PCL UNIT) of the image?
The lower-left margin is given in the raster page header as header->Margins, which is an array of 2 unsigned ints that express the margin in points. You are given the size of the page as header->PageSize, another array of 2 unsigned ints expressed as points. Finally, the header contains header->ImagingBoundingBox, an array of 4 unsigned ints that expresses the bounding box of the imaged area in points. With all of these values, realize that the coordinate system, measured in points, has (0,0) as the lower left hand corner of the media. You will need to calculate and translate to your PCL coordinate system.
Have you looked at the sample CUPS driver rastertohp.c? That is probably much of what you are looking for, as it takes in CUPS raster format and produces HP PCL.
--
Roger L Long
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Printing mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/printing/email@hidden
This email sent to email@hidden