Re: commit: Infrastructure for tighly wrapped images.

From: Ryan Pavlik <abiryan_at_ryand.net>
Date: Fri Feb 25 2005 - 00:53:54 CET

This looks like it may be really slick! Is there a way to add support
for "transparent=(pixelcolor==pagecolor)", since as much as we'd like,
not a huge amount of people use Transparent PNG? This would permit JPG
insertion perhaps, and while it wouldn't be perfect (compression
artifacts), I think it might be worthwhile. I believe Word does this,
but I'm not positive: I am allergic to Word's image handling, or vice
versa perhaps.

Ryan

msevior@physics.unimelb.edu.au wrote:

>CVS: ----------------------------------------------------------------------
>CVS: Enter Log. Lines beginning with `CVS:' are removed automatically
>CVS:
>CVS: Committing in .
>CVS:
>CVS: Modified Files:
>CVS: src/af/gr/cocoa/gr_CocoaImage.h
>CVS: src/af/gr/cocoa/gr_CocoaImage.mm
>CVS: src/af/gr/unix/gr_UnixImage.cpp src/af/gr/unix/gr_UnixImage.h
>CVS: src/af/gr/win/gr_Win32Image.cpp src/af/gr/win/gr_Win32Image.h
>CVS: src/af/gr/xp/gr_Image.cpp src/af/gr/xp/gr_Image.h
>CVS: src/af/gr/xp/gr_VectorImage.cpp src/af/gr/xp/gr_VectorImage.h
>CVS: src/af/xap/unix/xap_UnixPSGraphics.cpp
>CVS: src/af/xap/unix/xap_UnixPSImage.cpp
>CVS: src/af/xap/unix/xap_UnixPSImage.h
>CVS: ----------------------------------------------------------------------
>Some infrastructure for tight wrapped images.
>
>This commit provides a lot of the infrastructure needed for tight text
>wrapping around images and objects.
>
>This is where the text encroaches into the rectangular box which encloses
>images with large areas of transparency such as are often found in clip
>art collections and in particular in the open clip art collect at:
>
>I must admit part of my reason for working on this code is because I want
>abiword screenshots to be featured along side OOo shots on that site. I
>also remember being really impressed when I first saw this feature in MS
>Word 97 and wondered how they did it. So here we go :-)
>
>The way I intend to implement this is to increase the length of the lines
>placed around wrapped images to reflect the transparency of the object.
>
>So we need to work out if an image has transparency and where the first
>non-transparent pixel is on each row of the image.
>
>To do this we need two additional platform-specific methods for the
>GR_Image class. These are:
>
>virtual bool isTransparentAt(UT_sint32 x, UT_sint32 y) =0;
>virtual bool hasAlpha (void) const = 0;
>
>These are pure virtual in the GR_Image base class. I've implemented these
>for the Unix framework and have placed code that asserts in the Win32 and
>Cocoa builds. I haven't tested these. So once again, my apologies if these
>break those builds - it should be easy to fix though.
>
>The method "hasAlpha" simply returns true if there is any transparency in
>the image. If there isn't all the rest of the code is shorted circuited.
>
>The method "isTransparentAt(x,y)" returns true if the pixel at the device
>location (x,y) is pure transparent. This is a simple method that just
>calculates the the location of the pixel at (x,y) and determines if it's
>totally transparent.
>
>With these platform-specific methods we can now implement the XP methods
>in GR_Image. These are:
> void GenerateOutline(void);
> void DestroyOutline(void);
> UT_sint32 GetOffsetFromLeft(GR_Graphics * pG, UT_sint32 pad, UT_sint32
>yTop, UT_sint32 height);
> UT_sint32 GetOffsetFromRight(GR_Graphics * pG, UT_sint32 pad, UT_sint32
>yTop, UT_sint32 height);
>
> bool isOutLinePresent(void) const
> { return (m_vecOutLine.getItemCount() > 0);}
>
>The GenerateOutline method scans the image from the left and right sides
>for the first non-transparent pixel at each row of the image. As it finds
>this pixel it records it's location in the simple little class
>
>class ABI_EXPORT GR_Image_Point
>{
>public:
> GR_Image_Point(void) : m_iX(0),m_iY(0)
> {}
> UT_sint32 m_iX;
> UT_sint32 m_iY;
>};
>
>then saves each point in the vector
>
> UT_GenericVector<GR_Image_Point *> m_vecOutLine;
>
>This vector contains the outline of the non-transparent portions of the
>image. The "DestroyOutline(void)" method simply clears out this vector.
>
>The methods:
>
>UT_sint32 GetOffsetFromLeft(GR_Graphics * pG, UT_sint32 pad, UT_sint32
>yTop, UT_sint32 height);
> UT_sint32 GetOffsetFromRight(GR_Graphics * pG, UT_sint32 pad, UT_sint32
>yTop, UT_sint32 height);
>
>Are what will be actually used to implement the tight wrapping feature. I
>will implement these by intelligently scanning the the outline and
>determining the closest approach of each pixel to the line segment given.
>I've worked out the maths for this but it's not implemented yet.
>
>I'll send another post with this info.
>
>Cheers
>
>Martin
>
>
>
>

-- 
Ryan Pavlik
--
"Forget injuries, never forget kindnesses."  --Confucius
Received on Fri Feb 25 00:53:38 2005

This archive was generated by hypermail 2.1.8 : Fri Feb 25 2005 - 00:53:38 CET