Попробуйте эту функцию:
| Код | public: // User declarations __fastcall TForm2(TComponent* Owner); HRGN CreateBmpRgn(char *filName,TColor ATransparentColor);
HRGN TForm2::CreateBmpRgn(TPicture *APicture, TColor ATransparentColor) { //APicture - рисунок //ATransparentColor - ненужный цвет HRGN tmpRgn,wndRgn; wndRgn=CreateRectRgn(0,0,0,0); tmpRgn=CreateRectRgn(0,0,0,0); // цикл по высоте картинки for(int y = 0; y < APicture->Height; y++) { int x = 0; // изменяем ширину картинки while(x < APicture->Width) { while((x < APicture->Width) && (APicture->Bitmap->Canvas->Pixels[x][y] == ATransparentColor)) x++; // if(x >= APicture->Bitmap->Width) break; if (x!=APicture->Width) { int XStart = x; while((x < APicture->Width) && (APicture->Bitmap->Canvas->Pixels[x][y] != ATransparentColor)) x++; tmpRgn=CreateRectRgn(XStart,y,x,y+1); CombineRgn(wndRgn, wndRgn, tmpRgn, RGN_OR); } } }
SetWindowRgn(Handle, wndRgn, TRUE); DeleteObject(wndRgn); DeleteObject(tmpRgn); return wndRgn; }
void __fastcall TForm2::FormCreate(TObject *Sender) { Graphics::TPicture *APicture = new Graphics::TPicture(); APicture->LoadFromFile("1.bmp"); CreateBmpRgn(APicture, clFuchsia); } |
|