Sik
Member
For all who uses C++ and Allegro, I created a fast blur algorithm, yeah, I mean the effect of the fast blur of the Gens:
Here the video buffer is named "video_buffer", and is 320×224, with a 16-bits depth. I don't suggest use it in high resolutions, but you can always stretch after do it ;) If you think that stretching is slow, then is because you tried to stretch directly to the video card :P Use a temporal buffer instead, and then blit normally.
If you want to use 15-bits of depth, change the 16 -> 24 bits conversion code (the one between the _getpixels() and color3 = makecol16(...)) for use the correct alignement. Under 24/32-bits mode, delete that code.
And change the 16 at the end of _getpixel, _putpixel and makecol to the correct one.
If you want to be able to use different depths, use ifs() and select the correct algorithm :P
What do you think? I tested it and yes, it's fast. Really. I used under a program which runs at 60FPS virtually (VIRTUALLY, another example of virtual frame-rate is Sonic Action, which runs virtually at 100FPS, yes, I mean machine-idependant (did I mispelled it?) speed).
Code:
unsigned short xl;
unsigned char yl;
unsigned long color1;
unsigned long color2;
unsigned long color3;
for (yl = 0; yl < 224; yl++)
for (xl = 0; xl < 321; xl++) {
color1 = _getpixel16(video_buffer, xl, yl);
color2 = _getpixel16(video_buffer, xl + 1, yl);
color1 =
(color1 >> 11 << 19) + (((color1 >> 5) & 63) << 10) +
((color1 & 31) << 3);
color2 =
(color2 >> 11 << 19) + (((color2 >> 5) & 63) << 10) +
((color2 & 31) << 3);
color3 =
makecol16((color1 >> 16) + (color2 >> 16) >> 1,
((color1 >> 8) & 255) + ((color2 >> 8) & 255) >> 1,
(color1 & 255) + (color2 & 255) >> 1);
_putpixel16(video_buffer, xl, yl, color3);
}
If you want to use 15-bits of depth, change the 16 -> 24 bits conversion code (the one between the _getpixels() and color3 = makecol16(...)) for use the correct alignement. Under 24/32-bits mode, delete that code.
And change the 16 at the end of _getpixel, _putpixel and makecol to the correct one.
If you want to be able to use different depths, use ifs() and select the correct algorithm :P
What do you think? I tested it and yes, it's fast. Really. I used under a program which runs at 60FPS virtually (VIRTUALLY, another example of virtual frame-rate is Sonic Action, which runs virtually at 100FPS, yes, I mean machine-idependant (did I mispelled it?) speed).