I draw a filled circle in a square with transparent background and fill color using gdi+ on the DC of a bitmap. Since I need to copy the circle at different positions, so if the fill color is opaque, then I use bitblt do some simple alpha blending:
for(int i=0; i<num; ++i) {
destDC->BitBlt(lx[i], ly[i], lwidth, lheight, srcDC, 0, 0, SRCAND);
}
if the fill color is semi-transparent, then I need the pixel-wise alpha blending:
BLENDFUNCTION f;
f.BlendOp = AC_SRC_OVER;
f.BlendFlags = 0;
f.SourceConstantAlpha = 255;
f.AlphaFormat = AC_SRC_ALPHA;
for(int i=0; i<num; ++i) {
AlphaBlend(destDC->m_hDC, lx[i], ly[i], lwidth, lheight,
srcDC.m_hDC, 0, 0, lwidth, lheight, f);
}
Question: why the circles drawn by BitBlt and AlphaBlend look slightly different? I mean the positions and shapes of the circles are a little bit different? I get stuck in this problem for a while, since the draw performance when the fill color is opaque is really important, I cannot simply drop the BitBlt function here. Is any workaround to handle this problem?
A small hint: when I draw using TransparentBlt for the opaque case, the positions and shapes of the circles are exactly the same as using AlphaBlend for the semi-transparent case. But the performance of TransparentBlt is not good enough.