//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CGRID"
#pragma resource "*.dfm"
int a = 0;
TForm1 *Form1;
TPoint MPoint, StartDot;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Image1->Picture->Bitmap->Height = 305;
Image1->Picture->Bitmap->Width = 320;
ListBox1->ItemIndex = 0;
this->DoubleBuffered=true;
}
//---------------------------------------------------------------------------
TPoint stPt1,stPt2;
int iPBrushWid=3;
void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
if(Shift.Contains(ssLeft)){
if(a==1){ // 연필
Image1->Picture->Bitmap->Canvas->LineTo(X,Y);
}
if(a==2){ // 빗금
TPoint cuPt1,cuPt2,cuPt3,cuPt4;
cuPt1=Point(X-iPBrushWid,Y-iPBrushWid);
cuPt2=Point(X+iPBrushWid,Y+iPBrushWid);
TPoint p[5]={stPt1,stPt2,cuPt2,cuPt1,stPt1};
Image1->Canvas->Polygon(&p[0],4);
stPt1=cuPt1;
stPt2=cuPt2;
}
if(a==3)//사각형
{
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
Image1->Canvas->Brush->Color= CColorGrid1->ForegroundColor;
Image1->Picture->Bitmap->Canvas->Pen->Color = CColorGrid1->ForegroundColor;
Image1->Picture->Bitmap->Canvas->Pen->Width = ListBox1->ItemIndex+1;
if(a==1){
Image1->Picture->Bitmap->Canvas->MoveTo(X,Y);}
if(a==2){
stPt1=Point(X-iPBrushWid,Y-iPBrushWid);
stPt2=Point(X+iPBrushWid,Y+iPBrushWid);
}
if(a==3){
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (SaveDialog1->Execute())
Image1->Picture->Bitmap->SaveToFile(SaveDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if (OpenDialog1->Execute())
Image1->Picture->Bitmap->LoadFromFile(OpenDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
a = 2;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton3Click(TObject *Sender)
{
a = 1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton2Click(TObject *Sender)
{
a = 3;
}
//---------------------------------------------------------------------------
|