Skip to content

Commit

Permalink
Engine: fixed DrawSurface alpha transparency + transparency limit check
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Jan 23, 2022
1 parent bc22c64 commit 2710b99
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Engine/ac/drawingsurface.cpp
Expand Up @@ -124,8 +124,12 @@ ScriptDrawingSurface* DrawingSurface_CreateCopy(ScriptDrawingSurface *sds)
}

void DrawingSurface_DrawSurface(ScriptDrawingSurface* target, ScriptDrawingSurface* source, int translev) {
if ((translev < 0) || (translev > 99))
quit("!DrawingSurface.DrawSurface: invalid parameter (transparency must be 0-99)");
if ((translev < 0) || (translev > 100))
quit("!DrawingSurface.DrawSurface: invalid parameter (transparency must be 0-100)");

// 100% transparency, don't draw anything
if (translev == 100)
return;

Bitmap *ds = target->StartDrawing();
Bitmap *surfaceToDraw = source->GetBitmapSurface();
Expand All @@ -144,8 +148,8 @@ void DrawingSurface_DrawSurface(ScriptDrawingSurface* target, ScriptDrawingSurfa
quit("!DrawingSurface.DrawSurface: 256-colour surfaces cannot be drawn transparently");

// Draw it transparently
GfxUtil::DrawSpriteWithTransparency(ds, surfaceToDraw, 0, 0,
GfxDef::Trans100ToAlpha255(translev));
draw_sprite_support_alpha(ds, target->hasAlphaChannel != 0, 0, 0, surfaceToDraw, source->hasAlphaChannel != 0,
kBlendMode_Alpha, GfxDef::Trans100ToAlpha255(translev));
target->FinishedDrawing();
}

Expand Down

0 comments on commit 2710b99

Please sign in to comment.