PDA

Tam Sürümünü Görmek İçin : parçaları sürükleyerek tamamlama


sebnemkaya86
04/06/2007, 17:56
Yeni bir proje açtım. Formun üzerine 1 tane TImage yerleştirdim.Header dosyasında Form1 in public kısmına aşağıdaki satırı ekledim:

// Unit1.h için
void __fastcall ResmiBol(Graphics::TBitmap* bmp);


Aşağıdaki satırlarıda Source dosyasına ekledim:

// Unit1.cpp için
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Graphics::TBitmap* bmp = new Graphics::TBitmap;
bmp->LoadFromFile("dosya_ismi.bmp");

int nWidth = bmp->Width;
int nHeight = bmp->Height;

if (Image1 && bmp)
{
Image1->Width = nWidth;
Image1->Height = nHeight;
ResmiBol(bmp);
}
delete bmp;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ResmiBol(Graphics::TBitmap* bmp)
{
int nWidth = bmp->Width / 24;
int nHeight = bmp->Height / 24;
POINT ptRandom[576];
int nCount = 0;

srand((unsigned)time(NULL));

while(nCount < 576)
{
ptRandom[nCount].x = rand() % 24;
ptRandom[nCount].y = rand() % 24;

for (int s = nCount - 1; s >= 0 && nCount > 0; s--)
{
if (ptRandom[s].x == ptRandom[nCount].x &&
ptRandom[s].y == ptRandom[nCount].y)
{
nCount--;
break;
}
}
nCount++;
}

nCount = 0;
for (int i = 0; i < 24; i++)
{
for (int j = 0; j < 24; j++)
{
::BitBlt((HDC)Image1->Canvas->Handle,
(ptRandom[nCount].x * nWidth), (ptRandom[nCount].y * nHeight),
nWidth, nHeight,
bmp->Canvas->Handle,
(j * nWidth), (i * nHeight),
SRCCOPY);
TRect rc;
rc.left = ptRandom[nCount].x * nWidth;
rc.top = ptRandom[nCount].y * nHeight;
rc.right = rc.left + nWidth;
rc.bottom = rc.top + nHeight;
::FrameRect((HDC)Image1->Canvas->Handle, &rc,
GetStockObject(BLACK_PEN));
nCount++;
}
}
}


resmi bölmeyi başardım fakat yapboz yapmam gerekli,yani bu parçaları sürükle-bırak yöntemi ile bir alanda düzgün hâle getirmem gerekli..bunu nasıl yapabilirim?