Skip to main content
Inspiring
July 16, 2013
Question

Rasterize the document

  • July 16, 2013
  • 2 replies
  • 1837 views

Hi

I want to rasterize the document each time the user makes an action that changes the contents.

The AIRasterizeSuite makes a raster art object from an artset with the method Rasterize.
This method can be quite time consuming and alters the document by adding a new object (the raster art).

Can I use The AIArtDrawArtSuite to rasterize the document and how I can get an ArtHandle from the whole document ?

Do I need to make a group object and move the visible artworks in this group ?

Is this suite is fast enough to be used for each change ?

This topic has been closed for replies.

2 replies

Participating Frequently
July 17, 2013

Hi nosleduc,

You can find an example of how to use the AIDrawArtSuite in the DrawArt and DrawArtUI sample in the SDK. The sample gets the pixel data for a swatch and passes that across for display in flash ui. That might help you get started using the AIDrawArtSuite.

I hope that helps,

Thanks,

Robert

nosleducAuthor
Inspiring
July 17, 2013

Hi

Yes I've already looked this example. It draws a color swatch.

I was wondering if someone has used the AIDrawArtSuite to rasterize a document and if yes how it proceeds.

In fact I want to update an OpenGL texture from the document each time the user changes the contents.

I can update only a sub part of the texture if it is possible to know which portion of the document has changed.

But I need something fast to rasterize the document or a sub-part of the document.

I'm searching a mean to do that. Any suggestions ?

A. Patterson
Inspiring
July 16, 2013

You can rasterize the whole document, but there are some hurdles:

  1. You'll need to get an AIArtSet that contains the whole document -- this one is actually not to hard if you look at AIArtSet.h
  2. Rasterizing the whole document will not be fast probably, depending on how much art there is.
  3. There is a high liklikhood that the rasterizer will not be able to rasterize the whole document at once; it has a limit of somewhere in the neighbourhood of 3k x 3k pixels -- it doesn't take much to get to that limit.

There's not much you can do about #2 but #3 is solvable, its just annoying. Basically, you can tell the rasterizer to only rasterize the artset as specified by an AIRealRect. If you 'tile' the document you can rasterize it in chunks that are less than the rasterizer limit and then assemble the results. We do something like this in our plugin but there is a lot of work involved and we rely on several 3rd party libraries, a couple of which are proprietary.

So it is doable, its just a fair bit of work!

nosleducAuthor
Inspiring
July 16, 2013

I know how to use the AIRasterize suite. I'm using it to export an image of a sub-part of the document and indeed I use tiles to rasterize the document. I rasterize the document when the user clicks on a button. In general it takes less than three seconds. It can take about 10 seconds in the worst case. But it is acceptable.

If now I'm tracking the changes of the document this method cannot be used.

I was wondering how Illustrator renders the document.  When you change something in the document, Illustrator renders it instantly.

Is there is any chance to get something close in terms of performance ? I don't want necessary to get something really accurate. The purpose of it is to provide a quick preview. That's why I was asking about the AIArtDrawArtSuite suite

A. Patterson
Inspiring
July 17, 2013

AIDrawArt.h is basically an internal header. The only useful method in that suite I've ever managed to use is DrawHilite().

Hmmm. Looking at the headers, I might be wrong. It looks like they finally may have added the methods needed to actually use the AIDrawArt suite in CS6; not sure how I missed that. CreateImagePort, GetImagePixelData & DestroyImagePort were definitely not there in CS5. That said, it'll take some experimenting to see if it really is usable now.