Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Graphics 在SDL/Pascal中将32位精灵设置为50%不透明度?_Graphics_Sdl_Freepascal - Fatal编程技术网

Graphics 在SDL/Pascal中将32位精灵设置为50%不透明度?

Graphics 在SDL/Pascal中将32位精灵设置为50%不透明度?,graphics,sdl,freepascal,Graphics,Sdl,Freepascal,我正在做其他人的游戏,不熟悉SDL或Pascal。我想做的是将游戏图形从8位升级到32位。到目前为止,除以下程序外,一切进展顺利: SDL_SetAlpha( Spr^.Img , SDL_SRCAlpha , Alpha_Level ); DrawAnimImage( Spr^.Img , Spr^.W , Spr^.H , Frame , MyDest ); SDL_SetAlpha( Spr^.Img , SDL_SRCAlpha , SDL_Alpha_Opaqu

我正在做其他人的游戏,不熟悉SDL或Pascal。我想做的是将游戏图形从8位升级到32位。到目前为止,除以下程序外,一切进展顺利:

    SDL_SetAlpha( Spr^.Img , SDL_SRCAlpha , Alpha_Level );
    DrawAnimImage( Spr^.Img , Spr^.W , Spr^.H , Frame , MyDest );
    SDL_SetAlpha( Spr^.Img , SDL_SRCAlpha , SDL_Alpha_Opaque );
当角色靠近精灵时,此代码将精灵的不透明度更改为50%。它适用于8位或可能24位图像,但不适用于32位图像。如何重写此代码以使用alpha通道处理32位图像

这篇老博客文章描述了我需要做什么,但我是个书呆子,并不完全理解

它提到了一个名为Sprig的库。这是我唯一的选择吗?我如何使用它?它与Pascal程序一起工作吗


谢谢。

这不是一件容易的事情,因为您必须手动重新计算srcsurface alpha(需要先保存以前的alpha,以后再恢复)。这不是初学者会做的事情(这里没有什么太难的,但需要处理原始内存中的像素和位掩码)。但是,如果初始图形没有alpha通道,为什么要首先使用RGBA?我从头开始用32位重新创建了所有图形。我提到的Sprig库呢?