[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: How to convert to Standard WMF?
From:       Nicolas Goutte <nicolasg () snafu ! de>
Date:       2003-01-08 16:40:00
[Download RAW message or body]

On Wednesday 08 January 2003 22:04, Clarence Dang wrote:
> Hi Nicolas,
>
> Thanks for the source code pointers on WMF.  I've managed to write a
> BMP-to-WMF converter function.  But I still have a few questions about the
> RTF export filter (ExportFilter.cc) and image manipulation in general:
>
> 1. Given a BMP, how do I make sure that it's a DIB, not a DDB (is there an
> easy conversion function or are all QT BMPs DIBs?)?

Device-depedent bitmap were for BMP of Windows 1.X and 2.X and should not 
exist much anymore.

As far as I could see from the code, QT only writes standard uncompressed 
Windows 3.x BMP files (in the QT's file src/kernel/qimage.cpp.)

You can check a BMP file yourself. If it starts with the character B and M, it 
is a Windows 3.x or OS/2 image (device-independant). If it starts with 0 (16 
bit value), it is a Windows 1.x image (device-dependant.)

>
> 2. What is the easiest way to convert a 32-bit BMP (stored in a QByteArray)
> to a 16-bit BMP (QT doesn't support 24?)?  I mean QImage::convertDepth
> works but QImage::save can't write to a QByteArray and I don't want to
> write to a temporary file...

2a: in 32 bit mode, QT write 24 bit BMP images. As 16 bit BMP is non-standard 
("multimedia extensions"), QT does not seem to support it.

2b: for saving, you can use QImageIO and QBuffer. See the method 
AbiWordWorker::convertUnknownImage in the file 
koffice/filters/kword/abiword/abiwordexport.cc (lines 262-301.)

>
> 3. How do I find out the original width/height of a WMF?  I don't
> understand the code in ExportFilter.cc starting from "// d7cdc69a is
> metaheader magic id" because IIRC, the magic for a WMF is not d7cdc69a (at
> least not for "Standard WMFs")?

0x9ac6cdd7 is the magic of the WMF *special* header. This header contain left, 
top, right, bottom values. (See in the file koffice/lib/kwmf/wmfstruct.h, the 
structure is called WmfPlaceableHeader (lines 79-87))

It is an additional header, specially for files to get the information quickly 
instead to have to find the information somewhere in the metafile.

If I remember well, the Windows's WMF system do not know this special header 
and therefore it must be stripped out. That is also the reason why it must go 
for RTF, as RTF assume that the RTF stream is ready to use.

As for the height/width of a WMF, you would have two ways to do it in KOffice:
- high level: load the WMF to a KoPIcture (KoPicture::load) and use 
KoPicture::getOriginalSize.
- low level: load the picture qo a QWinMetaFile  (QWinMetaFile::load) and use 
QWinMetaFile::bbox (I have no idea if it really works if the WMF file has no 
special header.)

H'm, I am just thinking that you need to know how it works and not to know how 
to use it. So in QWmfMetaFile check the setWindow methods.

>
> Thanks,
> Clarence

Have a nice day/evening/night!

>
> On Fri, 3 Jan 2003 03:41 pm, Nicolas Goutte wrote:
> > Good question! ;-)
> >
> > The KOffice WMF source files are at
> > koffice/lib/kwmf/*
> > koffice/ib/kofficecore/koPictureWmf.*
> >
> > For anything QImage-based, I suppose that it should be not too difficult.
> > You have to reverse QWinMetaFile::dibBitBlt (in the file
> > koffice/kwmf/qwmf.cc)
> >
> > (See the KWord's AbiWord, HTML and RTF export filters for picture code,
> > mostly to PNG, JPEG and SVG.)
> >
> > The problems are as always: EPS, QPicture and SVG.
> >
> > For EPS, you can convert it to a bitmap easily. For the other metafile
> > formats, you can use KoPicture::generatePixmap. (A new method for
> > KoPicture to get a QImage whetever the internal file format of KoPicture
> > is planned but not yet done.)
> >
> > If you want to convert the metafiles 1:1, it gets more complex. For EPS,
> > I have no idea how to do it (probably a new driver for GhostScript.) For
> > QPIcture (and therefore also for SVG), you would probably have to use the
> > same trick as for saving SVG from QPicture. The problem is that
> > QSvgDevice uses many non-document features of QT to be able to work. .-(
> >
> > So that is what I know about exporting to WMF. May be I have missed
> > easier ways.
> >
> > Have a nice day/evening/night!
> >
> > On Saturday 04 January 2003 00:00, Clarence Dang wrote:
> > > Hi,
> > >
> > > How do I convert a picture to a "Standard Windows Metafile" for a KWord
> > > export filter (in code, not via the GUI)?
> > >
> > > Thanks,
> > > Clarence
>
> _______________________________________________
> koffice-devel mailing list
> koffice-devel@mail.kde.org
> http://mail.kde.org/mailman/listinfo/koffice-devel

_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic