[haiku-development] Integer image scaling code

  • From: Michael Crawford <mdcrawford@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 23 Sep 2009 00:46:54 -0700

Hey Folks,

A while back I wrote an image scaler in C++ that used only integer
math.  It was quite fast; even on a 150 MHz PowerPC Mac, I could drag
my mouse rapidly around on the resize handle for an image, and it
would keep up with my movements with very little lag.  I'm sure that
on today's processors it would be blazing.

Now this wouldn't be an advantage on modern x86 processors that have
vectorized floating point.  But possibly it would on the ARM port of
Haiku, or on older x86 chips that have more modest capabilities.  Many
embedded chips don't have hardware floating point, and even some chips
that do, can't do it as fast as integer.

This code included alpha channel support, so the image could be
transparent or semitransparent, and it would do the right thing.

If you think Haiku could use it, I'll dig up the code and make a
standalone demo.

There is one other advantage to it over floating point methods: some
CPUs have multiple integer units but only one FPU.  So doing an
intensive operation in integer can potentially be faster even if a
floating point operation is as fast as an integer op.

Mike
-- 
Michael David Crawford
mdcrawford at gmail dot com

   GoingWare's Bag of Programming Tricks
      http://www.goingware.com/tips/

Other related posts: