Unfortunately, unless I'm doing something wrong neither of your suggestions achieves the desired effect. Here's some example code that shows that using COMPFLAG_SrcAlphaOverride will lead to a constant alpha value of 0xff in the destination bitmap instead of the alpha value from the source bitmap (0x80).
Code: Select all
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cybergraphx/cybergraphics.h>
#include <exec/exec.h>
#include <graphics/composite.h>
#include <graphics/gfx.h>
#include <graphics/rpattr.h>
#include <intuition/intuition.h>
#include <intuition/IntuitionBase.h>
#include <intuition/screens.h>
#include <proto/cybergraphics.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/picasso96api.h>
struct Library *IntuitionBase = NULL;
struct IntuitionIFace *IIntuition = NULL;
struct Library *GfxBase = NULL;
struct GraphicsIFace *IGraphics = NULL;
struct Library *P96Base = NULL;
struct P96IFace *IP96 = NULL;
struct Library *CyberGfxBase = NULL;
struct CyberGfxIFace *ICyberGfx = NULL;
static struct Screen *myscr;
static struct BitMap *allocvbmap(int width, int height)
{
return AllocBitMap(width, height, GetBitMapAttr(myscr->RastPort.BitMap, BMA_DEPTH), BMF_MINPLANES|BMF_DISPLAYABLE, myscr->RastPort.BitMap);
}
int main(int argc, char *argv[])
{
struct Window *win;
struct BitMap *bmap, *bmap2, *bmap3;
ULONG ilock;
struct RastPort tmprp;
int borderleft, bordertop;
struct IntuiMessage *msg;
int width = 320, height = 240, k;
float sx = 2, sy = 2;
IntuitionBase = OpenLibrary("intuition.library", 53);
IIntuition = (struct IntuitionIFace *) GetInterface(IntuitionBase, "main", 1, NULL);
GfxBase = (struct Library *) OpenLibrary("graphics.library", 0);
IGraphics = (struct GraphicsIFace *) GetInterface(GfxBase, "main", 1, NULL);
CyberGfxBase = OpenLibrary("cybergraphics.library", 0);
ICyberGfx = (struct CyberGfxIFace *) GetInterface(CyberGfxBase, "main", 1, NULL);
P96Base = OpenLibrary("Picasso96API.library", 0);
IP96 = (struct P96IFace *) GetInterface(P96Base, "main", 1, NULL);
ilock = LockIBase(0);
myscr = ((struct IntuitionBase *) IntuitionBase)->ActiveScreen;
UnlockIBase(ilock);
borderleft = myscr->WBorLeft;
bordertop = myscr->WBorTop + myscr->Font->ta_YSize + 1;
bmap = allocvbmap(640, 480);
bmap2 = allocvbmap(width, height);
bmap3 = allocvbmap(640, 480);
InitRastPort(&tmprp);
tmprp.BitMap = bmap;
FillPixelArray(&tmprp, 0, 0, 640, 480, 0);
tmprp.BitMap = bmap2;
FillPixelArray(&tmprp, 0, 0, width, height, 0x80FF0000);
tmprp.BitMap = bmap3;
FillPixelArray(&tmprp, 0, 0, 640, 480, 0xFFFFFFFF);
win = OpenWindowTags(NULL,
WA_Left, 100,
WA_Top, 100,
WA_InnerWidth, 640,
WA_InnerHeight, 480,
WA_SizeGadget, FALSE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_Borderless, FALSE,
WA_SimpleRefresh, TRUE,
WA_IDCMP, IDCMP_CLOSEWINDOW,
WA_Activate, TRUE,
WA_Title, "Test",
TAG_DONE);
CompositeTags(COMPOSITE_Src_Over_Dest, bmap2, bmap,
COMPTAG_ScaleX, COMP_FLOAT_TO_FIX(sx),
COMPTAG_ScaleY, COMP_FLOAT_TO_FIX(sy),
COMPTAG_Flags, COMPFLAG_SrcAlphaOverride,
TAG_DONE);
tmprp.BitMap = bmap;
printf("CHECK SCALE RESULT: %lx\n", ReadRGBPixel(&tmprp, 0, 0));
CompositeTags(COMPOSITE_Src_Over_Dest, bmap, bmap3,
COMPTAG_Flags, COMPFLAG_IgnoreDestAlpha,
TAG_DONE);
BltBitMapRastPort(bmap3, 0, 0, win->RPort, borderleft, bordertop, 640, 480, 0xc0);
for(k = 0; k < 200; k++) WaitTOF();
FreeBitMap(bmap);
FreeBitMap(bmap2);
FreeBitMap(bmap3);
CloseWindow(win);
DropInterface((struct Interface *) IIntuition);
CloseLibrary(IntuitionBase);
DropInterface((struct Interface *) IGraphics);
CloseLibrary(GfxBase);
DropInterface((struct Interface *) ICyberGfx);
CloseLibrary(CyberGfxBase);
DropInterface((struct Interface *) IP96);
CloseLibrary(P96Base);
return 0;
}
Note that using COMPFLAG_IgnoreDestAlpha as suggested by broadblues will lead to the alpha byte being zero in the destination bitmap so I left it out. gazelle's suggestion yields the same, wrong result.