png Alpha level

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
kuat
Posts: 5
Joined: Mon Mar 09, 2009 7:06 am

png Alpha level

Post by kuat »

Hi there, it's my first post and i have a question.
Is there any way to improve graphics.h to make a funcion wich you can set the level of alpha transparency?

Let me explain:
I'm trying to port a little fade in and fade out Allegro funcion that uses "set_trans_blender" method, and the lib graphics.h does'nt any funcion like that...



Sorry About my very bad english... =x
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Code: Select all

void XgeSetImageOpacity(XgeImage* image, int opacity)
{
    int i;
    int size = image->TextureWidth * image->TextureHeight;
    XgeColor* data = image->data;
    for&#40;i = 0; i < size; i++, data++&#41;
        *data = *data + &#40;&#40;&#40;int&#41;&#40;&#40;float&#41;&#40;&#40;float&#41;0xFF / 100.00f&#41; * &#40;float&#41;opacity&#41; - A&#40;*data&#41;&#41; << 24&#41;;
&#125;
;)
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

There is another formula that doesn't require so many float, should be faster.
kuat
Posts: 5
Joined: Mon Mar 09, 2009 7:06 am

Post by kuat »

Thanx guys!

i'll try it later =D
Post Reply