Posts Tagged ‘flash’

AIR 3 PDF Renderer extension (Mac OSX only)

October 2nd, 2011

There’s this new feature in AIR 3 – native extensions, and there’s that ever-existing problem, how to render PDF documents in flash. In web player that’s still not possible (well, unless you sacrifice one year for writing PDF renderer) but it’s possible in AIR, for example using native extensions.
MacOS-X has the Cocoa library(framework) which performs great in rendering PDF files so I’ve written an extension which uses this lib to send BitmapData object containing rendered PDF to flash. Of course this is possible in windows and linux too, using XPDF library for example. AIR native extensions are easily extendable and altering several things in files that I’ve provided should make that extension work on windows, linux and even mobile systems.

RenderPDF extension contents:
There are many files in the archive, but all of them were used to make an extension.
PDFExt_framework contains compiled OS-X framework.

PDFExt_XCode contains an objective-c (objective-c is needed for Cocoa library) framework project.

PDFExtTest is a test app using an extension. In sample_commands folder you have bash commands to compile and package the test app. Test app displays a pdf, allows page changing and saving current page as PNG image. Test app illustrates usage of RenderPDF extension methods:
get pageCount():int,
RenderPDF.renderPage( pageNum, dpi ):BitmapData ,
loadPDF( source:String ):Boolean

PDFExtTest app screenshot:

PDFExtAS is the source code for AS3 interface for an extension.
compiled – this folder contains compiled swc, extension, extension xml descriptor and sample commands for compiling and packagind everything into an .ane file.

Several remarks:
Before compiling the framework, you must add the Cocoa framework and Air framework to the project, and then exclude them from linking, as described on “Extending AIR” article. In Info.plist file you must add the DYLD_FORCE_FLAT_NAMESPACE env variable and in project settings you modify the “Runpath search path”.

If you’ll take a look into PDFExtM.m source file, you will see that returning a BitmapData object from native function involves quite a few steps.
Also, flash BitmapData sometimes contains some extra bytes at every scanline, so memcpy from native uint array to copy the bitmap won’t work, you must iterate every pixel and skip the extra bytes at the end of a scanline (maybe there’s some super clever low-level-memory-hacking method to do it faster).

Tags: , , ,
Posted in flash experiments | Comments (9)

Mesh decimation in flash

June 6th, 2009

I’ve implemented “new QEM” algorithm ( ) for mesh decimation, or other words – for simplifying meshes.

It supports appearance attributes, but when texture has many discontinuities – my decimator generates errors and your model can be jagged/distorted.



I’ve made a little web interface to allow you some testing.

Web interface:

You can download your decimated model and do whatever the hell you want with it.

I’ve also created a model viewer. I had to make custom pv3d camera control, because papervision3d’s Camera class has million bugs ( with rotations for example ). There are some bugs in environment mapping too, but I didn’t have time to fix them …

Here’s my mesh decimator with some trial models:

Here’s the viewer of 3d models:

Tags: , , , ,
Posted in flash experiments | Comments (0)