Re: Fwd: render.c:GetPixelOpacity() optimization ideas?

Wolfgang Spraul <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.core
Organization Q AG
Message-ID <[email protected]>
Bob -

(I think those are excellent tips so I'm replying through the list)

Bob wrote:
> Even if you don't really understand the algorithm at all, you can
> study how it operates.  You can learn the range of values.  Once you
> know the range of values, if they are always positive, negative, or
> either way, etc., you can define a scaled integer space.  For example,
> for a floating value which varies between 0.0 and 1.0, you could
> decide to use an integer range of 0 to 10000 (a power of 2 may be a
> better choice).  The computations would be done using this boosted
> range. Whatever range you choose needs to be high enough to avoid
> inaccuracy, and low enough that values don't go past the range of
> 'long' (or 'long long' if your CPU supports it efficiently). Input
> parameters would be converted to this range before use.  If anything
> needs to be saved, then it needs to be scaled back to a double to keep
> the rest of the code happy.
>
> I believe that the polygon agorithms were influenced strongly by
> libart (it used to be credited in render.c), which is used by GNOME.
>
> Since floating point is bad for you, you should look for floating
> point which can be eliminated.  For example, the many "0.5"s and
> "0.25"s are usually there to avoid round-off errors and each of these
> is consuming a floating point operation.  Maybe you don't care about
> round-off errors since they usually can't be seen.  They are there in
> order to help our tests pass (and to be pedantic).  It is important
> that the results be accurate enough that flood fills don't start going
> where they shouldn't.
>
> Bob

Thank you very much. This gives me confidence to get started, in case I cannot 
find any outside help ;-)
If you have any other references to books, articles, URLs, please let me know.
Once I start to do it, I will certainly report back in case there is anything 
of value for you or at least I have a patch to post somewhere...

Wolfgang



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.