Semi-transparent images render test
Posted: Sat Jun 21, 2014 3:18 am
For checking SMBX's image renderer, I made this little comparing of SMBX and PGE with new mask renderer (0.1-alpha, what support using of the Alpha-channel by masks (in 0.0.8 semi-transparent possible only by PNG, by masks you can get only 1-bit)). Masks give to using semi-transparent in image formats, what not supporting of internal transparent, example: BMP, JPG, or GIF, what have only one bit of transparency (PNG have 255 grades of semi-transparency).
Test #1
I made vertical gradient background image:
And gray-grade masks:
And run this interesting test:


Result:
- SMBX calculating image in real-time render by color-mixing, as you see, appeared a lot of color glitches.
- The PGE applying masks only on image-loading process, and calculated image saving in RAM, and after using always in working process.
Get this test
Test #2
Will be made test with horizontal gradient:
And graded masks of same sprite, but saved in npc-1, npc-2,...,npc-20:
And ran this test:


Result:
- SMBX uses Color-Mixing for imitating semi-transparency
- PGE uses a alpha-channel for generating target sprites from masks, and renders real semi-transparency.
Get this test
Test #3
Little programming examples:
For make real test, I got THIS example for Visual Basic 6 (Language, used for made SMBX):
http://www.vbexplorer.com/VBExplorer/gdi1.asp
And I replaced images to my SMBX's sprites:

And build them.
I take this result:

As you see, result is same, what displayed in SMBX.
VisualBasic 6 source, what creating this mask (And I think, this is same method, what uses in SMBX for render sprites)
All sources and test EXE of this you can get here: VB6 Mask Example.zip
In C++ with Qt I using mask for define alpha-channel of image:
https://github.com/Wohlhabend-Networks/ ... cs.cpp#L24
This allow to using any grades of semi-transparency.
But you must fix all lazy-made sprites (What is this?), what sometimes using in SMBX's custom graphics
Test #1
I made vertical gradient background image:
Spoiler: show
Spoiler: show


Result:
- SMBX calculating image in real-time render by color-mixing, as you see, appeared a lot of color glitches.
- The PGE applying masks only on image-loading process, and calculated image saving in RAM, and after using always in working process.
Get this test
Test #2
Will be made test with horizontal gradient:
Spoiler: show
Spoiler: show


Result:
- SMBX uses Color-Mixing for imitating semi-transparency
- PGE uses a alpha-channel for generating target sprites from masks, and renders real semi-transparency.
Get this test
Test #3
Little programming examples:
For make real test, I got THIS example for Visual Basic 6 (Language, used for made SMBX):
http://www.vbexplorer.com/VBExplorer/gdi1.asp
And I replaced images to my SMBX's sprites:

And build them.
I take this result:

As you see, result is same, what displayed in SMBX.
VisualBasic 6 source, what creating this mask (And I think, this is same method, what uses in SMBX for render sprites)
Code: Select all
Private Sub cmdDrawMask_Click()
'Draws the mask with vbSrcAnd raster operation
BitBlt Me.hDC, 0, 0, picMask.ScaleWidth, picMask.ScaleHeight, picMask.hDC, 0, 0, vbSrcAnd
End Sub
Private Sub cmdDrawSprite_Click()
'Draws the sprite witht the vbSrcPaint raster operation
BitBlt Me.hDC, 0, 0, picSprite.ScaleWidth, picSprite.ScaleHeight, picSprite.hDC, 0, 0, vbSrcPaint
End Sub
In C++ with Qt I using mask for define alpha-channel of image:
https://github.com/Wohlhabend-Networks/ ... cs.cpp#L24
Code: Select all
QPixmap setAlphaMask(QPixmap image, QPixmap mask)
{
if(mask.isNull())
return image;
if(image.isNull())
return image;
QImage target = image.toImage();
QImage newmask = mask.toImage();
if(target.size()!= newmask.size())
{
newmask = newmask.copy(0,0, target.width(), target.height());
}
newmask.invertPixels();
target.setAlphaChannel(newmask);
return QPixmap::fromImage(target);
}
But you must fix all lazy-made sprites (What is this?), what sometimes using in SMBX's custom graphics