In a recent thread i discussed with Marc the alpha bitmap design, and was pointed that would be no performance penalty if a 24bit bitmap is used in a 32bit color display since the number of bytes per pixel would be equal. Initially i agreed but i found that this info is incorrect.

A 24bit bitmap uses 4bytes/pixel (in average) in some sizes (1,2,3 pixels) to fill the dword boundary. When the dword boundary is filled with 3bytes/pixel (4 pixels), it will use 3 bytes/pixel, in other situations (5 pixels) the bytes/pixel is not constant. So a bitmap with 1,2,3 pixels will have the same size using 24bit or 32bit (4,8,12 bytes), a 4 pixels bitmap will use 12 bytes and 16 bytes respectively, a 5 pixels bitmap will have 16 and 20 bytes.

I also tested the performance of such issue. A program that bitblt 1000 times a 200x200 bitmap in a 32bit color display give the results below (an 77% overhead over 32bit bitmap). Attached is a program (used fpc 214, XP SP2, celeron D 1.4 512MB). In the other side 24bit bitmaps use less memory.

Although i disagree with the design/solution (using a 24bit bitmap by default in 32bit color display), that has performance issues and other side effects, the bitmap support improved with recent changes and i wont question this issue anymore, as the current LCL code.

The info here is just for clarify a misconception.

PS: with the recent changes (using CreateDIBSection to create the bitmap) alpha blend in VTV under win32 i near ;-) .

Luiz

Attachment: Bench24bit.rar
Description: Binary data

########################################
TChronoLog results - 2/9/2007 21:28:14
Session: 24bit first
Results (6):                              microsec     milisec     seconds
-------------------------------------   -----------   ---------   ---------
0 - 24bit                                   263.699         264           0
1 - 24bit                                   263.957         264           0
2 - 24bit                                   262.954         263           0
3 - 32bit                                   148.656         149           0
4 - 32bit                                   148.796         149           0
5 - 32bit                                   148.833         149           0

Accumulated (Miliseconds):        1.237

########################################
TChronoLog results - 2/9/2007 21:28:30
Session: 32bit first
Results (6):                              microsec     milisec     seconds
-------------------------------------   -----------   ---------   ---------
0 - 32bit                                   149.329         149           0
1 - 32bit                                   149.110         149           0
2 - 32bit                                   148.376         148           0
3 - 24bit                                   263.509         264           0
4 - 24bit                                   263.677         264           0
5 - 24bit                                   264.157         264           0

Accumulated (Miliseconds):        1.238

########################################
TChronoLog results - 2/9/2007 21:28:54
Session: Alternate
Results (6):                              microsec     milisec     seconds
-------------------------------------   -----------   ---------   ---------
0 - 24bit                                   264.219         264           0
1 - 32bit                                   148.475         148           0
2 - 24bit                                   264.444         264           0
3 - 32bit                                   148.353         148           0
4 - 24bit                                   264.141         264           0
5 - 32bit                                   149.036         149           0

Accumulated (Miliseconds):        1.239

Reply via email to