//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall DrawGripper (Graphics::TBitmap *Bmp, int X, int Y, int BH, int H, TCanvas *Canvas)
{
  Graphics::TBitmap *Tmp = new Graphics::TBitmap;
  Tmp->Width=Bmp->Width;
  Tmp->Height=Bmp->Height-2*BH;
  Tmp->Canvas->CopyRect(TRect(0,0,Bmp->Width,Tmp->Height),Bmp->Canvas,TRect(0,BH,Bmp->Width,Bmp->Height-BH));
  for (int i = 0; i < BH; i++)
  {
    for (int j = 0; j < Bmp->Width; j++)
      if (Bmp->Canvas->Pixels[j][i]!=Bmp->Canvas->Pixels[0][0])
        Canvas->Pixels[X+j][Y+i]=Bmp->Canvas->Pixels[j][i];
  }
  Canvas->StretchDraw(TRect(X,Y+BH,X+Bmp->Width,Y+H+BH),Tmp);
  for (int i = 0; i < BH; i++)
  {
    for (int j = 0; j < Bmp->Width; j++)
      if (Bmp->Canvas->Pixels[j][Bmp->Height-BH+i]!=Bmp->Canvas->Pixels[0][0])
        Canvas->Pixels[X+j][Y+H+i+1]=Bmp->Canvas->Pixels[j][Bmp->Height-BH+i];
  }
  delete Tmp;
}
void __fastcall TForm1::FormPaint(TObject *Sender)
{
  DrawGripper (Image1->Picture->Bitmap,0,0,5,(Image1->Picture->Bitmap->Height-10)*10,Canvas);
}
//---------------------------------------------------------------------------
