FreeImage_ConvertTo32Bits() from Conversion32.cpp has an important performance hit by calling the function FreeImage_IsTransparent in loops which causes some overhead.
You can define a boolean variable outside the loops like
BOOL bIsTransparent = FreeImage_IsTransparent(dib);.
then use it instead of calling the function.
The speed gain is 10-20%..
Anonymous
Further more, having two loops over each pixels can be avoided.
Currently there are two separate functions, each looping over the cols for each row
FreeImage_ConvertLine#To32 - actual conversion
MapTransparentTableToAlpha# - transparency mapping
I merged these functions to have a single loop. You can simply modify FreeImage_ConvertLine#To32
to include two additional parameters for transparency like this
FreeImage_ConvertLine#To32MapTransparency(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, palette, transparency_table, transparency_count);For example instead of
case 8:
{
for (int rows = 0; rows < height; rows++) {
FreeImage_ConvertLine8To32(FreeImage_GetScanLine(new_dib, rows), FreeImage_GetScanLine(dib, rows), width, FreeImage_GetPalette(dib));
You can have just:
case 8:
{
for (int rows = 0; rows < height; rows++) {
I am attaching the modified functions.
Modified Line conversion functions to handle transparency as well
I will add this to my TODO list.
I see a little problem here : you modified the signature of functions exposed by the FI interface : this would mean an incompatibility with previous FI 3.x versions, unless we also add some deprecated functions ...
I've added your patch to the CVS with some little modifications so that the FI Interface is not changed.
Hervé
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).