[Dev-luatex] How to crop bitmap images
Hans Hagen
pragma at wxs.nl
Mon Jul 1 22:06:03 CEST 2013
On 7/1/2013 9:10 PM, Patrick Gundlach wrote:
> Hello Hans,
>
>
>> best pack the img in a box and then put some qQ around it with the clip at the end (the usual experimenting with origin), so basically something compatible to
>>
>> \pdfliteral {q clip spec}
>> \pdfximage{...}
>> \pdfliteral {Q}
>>
>> ending up in something
>
> that works fine, thank you very much! This is my test code now:
>
> -----------------------
> \directlua{
> a=node.new("whatsit","pdf_literal")
> b=node.new("whatsit","pdf_literal")
> a.data = "q 0 w 20 20 m 140 20 l 140 160 l 20 160 l W n "
> b.data = "Q"
> image = img.scan{filename="cow.pdf"}
> i = img.node(image)
> node.insert_after(a,a,i)
> node.insert_after(a,i,b)
> head = node.hpack(a)
> tex.box[0] = head
> }
>
>
> \box0
>
> \bye
looks ok to me
> -----------------------
>
> I wonder how it compares to the slightly different approach pdflatex uses (pdftex.def?). If I see it correctly the graphicx package creates an xobject/form from the bitmap and changes the bounding box there.
i don't know (never looked into it) but maybe it's wrapped twice then,
once as image (form) and as box (form) or maybe they add a crop box in
the resources that then overloads the mediabox
but i guess that the clip is okay (i used that method for years)
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
More information about the dev-luatex
mailing list