1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| RECT rect1,rect2;
BOOL InFirstRegion = TRUE, InLine = FALSE;
m_picture.GetWindowRect(&rect1);
AfxGetMainWnd()->GetWindowRect(&rect2);
rect2.left = rect1.left;
rect2.top = rect1.top;
HDC hdc = m_picture.GetDC()->GetSafeHdc();
int StartLineX = 0;
//////////////////////////////
/////////////////////////////
//partie de faire transparence
////////////////////////////
///////////////////////////
for(y=0;y<rect1.bottom;y++)// for 1
{
for(x=0;x<rect1.right;x++) // for 2
{
if(GetPixel(hdc,x,y) == RGB(255,0,255))
{
if(InLine)
{
InLine = FALSE;
LineRegion = CreateRectRgn(StartLineX,y,x,y+1);
if(InFirstRegion)
{
FullRegion = LineRegion;
InFirstRegion = FALSE;
}
else
{
CombineRgn(FullRegion,FullRegion,LineRegion,RGN_OR);
DeleteObject(LineRegion);
}
}
}
else
{
if(!InLine)
{
InLine = TRUE;
StartLineX = x;
}
}
}//fin for 2
}//fin for 1
SetWindowRgn(FullRegion,TRUE); |
Partager