Saturday, 19 February 2011

Image Printing!

Once the image is encoded, the printing function should send the encoded data we are sending.
To make this happen i've made use of flash.printing.PrintJob.

For this i created a new function where i'm adding my print variable and a new PrintJob.

In order to get the "PrintJob" working we must let it know when to start, what to send to print and when to send it. So basically the data we are sending takes our previous effort of changing bitMaps to bitmapData to a new level, converting your data from bitmapData to bitmap and onto a Sprite... (phew!)

Once you have your Sprite ready (frame+the image+filter previously merged), the content of what we want to print has to make use of another PrintJob method, addPage().

addPage() sends the specified Sprite as a single page. Using this method involves adding the parameters required: a Sprite, and a rectangle (specifying the width and height of your Sprite).

toPrint.addPage(sprite, new Rectangle(0, 0, sprite.width, sprite.height), options)

So when clicking on the PRINT button, you'll get something like this:



In my case, I haven't got a printer plugged to my laptop, so i'll get a pdf version of it, in order to preview it.







This is the result!:






No comments:

Post a Comment