Re: Image generation of AbiWord files

From: <msevior_at_physics.unimelb.edu.au>
Date: Fri Feb 25 2005 - 15:08:49 CET

> Hi everyone,
>
> I'm new to AbiWord so please correct me if I make a mistake :-).
> Yesterday I had the idea to show little thumbnails of the templates in
> the 'New from template' dialog.
>
> Since I have no experience with contribing to AbiWord and have none to
> little experience with C++ it looks like a nice challange and
> oppertunity to give something to AbiWord.
>
> I discussed this little bit with uwog and he suggested that I could give
> a try and let other people know of what my idea is. I've opened an RFE
> bug[1] for it with some mockups and a detailed description.
>
> uwog noted that there is already some code available to generate PNG
> images of the first page of an AbiWord document. I'd like to know where
> it is located and how I can use it.
>
> Further, I'd like to receive your thoughts on this idea and every
> suggestion is welcome :-)
>
> Thanks in advance.
> >
> I'm new to AbiWord so please correct me if I make a mistake :-).
> Yesterday I had the idea to show little thumbnails of the templates in
> the 'New from template' dialog.
>
> Since I have no experience with contribing to AbiWord and have none to
> little experience with C++ it looks like a nice challange and
> oppertunity to give something to AbiWord.
>
> I discussed this little bit with uwog and he suggested that I could give
> a try and let other people know of what my idea is. I've opened an RFE
> bug[1] for it with some mockups and a detailed description.
>
> uwog noted that there is already some code available to generate PNG
> images of the first page of an AbiWord document. I'd like to know where
> it is located and how I can use it.
>
> Further, I'd like to receive your thoughts on this idea and every
> suggestion is welcome :-)
>
> Thanks in advance.
>

Hi Michiel,
             This is very similar to a feature I've been thinking about for a
while. This to show a preview of the document (the first few lines)
in the the file open dialog as soon as you select a file. The idea
is that you can tell at a glance if the selected file is the one you
want.

Before giving you my thoughts on the best way to implement your feature,
I'll answer your question about showing images of files. Yes there is a
method to do this already in the unix build of abiword. I implemented it
for integration with next-generation search tools.

The method is contained within the AP_UnixApp class.

 AP_UnixApp::makePngPreview(const char * pszInFile, const char *
pszPNGFile, UT_sint32 iWidth, UT_sint32 iHeight);

Which lives in abi/src/wp/ap/unix/ap_UnixApp.cpp

If you're working on unix you can easily get a pointer to this class from
anywhere in the unix source code by doing

AP_UnixApp * pUnixApp = static_cast<AP_UnixApp *>(XAP_APP::getApp());

and you have direct access to makePngPreview method.

The width and height are given in pixels. The method will adjust the zoom
level of the document to fit the width of the preview.

If you study this method you see it's basically just a wrapper around the
AP_Preview_Abi class.

This code lives in
src/wp/ap/xp/ap_PreviewAbi.(h,cpp)

It allows you to embed a non-scrolling document in any GR_Graphics class
drawable. I suggest that you take this route to display templates in a
(mostly) cross-platform dialog. You'll have to write a bit of platform
specific code to generate the GR_Graphics class but there are lots of
examples of how to do this in AbiWord.

Another example of the use of ap_Preview_Abi class is in
src/wp/ap/xp/ap_Dialog_Styles.(h,cpp)

Where the full effect of arbitrary changes in all the abiword text
properties are displayed in a preview.

Good Luck!

Feel free to ask more questions.

Martin

> Cheers,
> Michiel
>
> [1] http://bugzilla.abisource.com/show_bug.cgi?id=8486
>
Received on Fri Feb 25 15:10:15 2005

This archive was generated by hypermail 2.1.8 : Fri Feb 25 2005 - 15:10:18 CET