도형은 님이 그려주셔야지요. 뭐 시작점과 끝점을 연속으로 클릭하면 그걸 기준으로 원이나 사격형을 그리게 코딩을 하시든지
아니면 처음 클릭한(첫 시작점) 상태로 드래그해서 mouse-up이 일어나면 그 점을 끝점으로 하는 도형을 그려주시면 됩니다.
내부 비트맵을 하나 만드셔서 거기다가 해당 영역만큼 도형을 그린뒤 원본 화면에 XOR로 붙여주시든지..
XOR로 두번 덮어씌우면 원래 배경으로 돌아옵니다.
canvas에 있는 그리기 함수 응용해서 연구해보세요.
-locke
김준석 님이 쓰신 글 :
: 소스코드는 이거구요
:
: //---------------------------------------------------------------------------
:
: #include
: #pragma hdrstop
:
: #include "Unit1.h"
: //---------------------------------------------------------------------------
: #pragma package(smart_init)
: #pragma link "CGRID"
: #pragma resource "*.dfm"
: TForm1 *Form1;
: //---------------------------------------------------------------------------
: __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;
: }
: //---------------------------------------------------------------------------
:
: void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift,
: int X, int Y)
: {
: if(Shift.Contains(ssLeft))
: Image1->Picture->Bitmap->Canvas->LineTo(X,Y);
: }
: //---------------------------------------------------------------------------
: void __fastcall TForm1::Image1MouseDown(TObject *Sender,
: TMouseButton Button, TShiftState Shift, int X, int Y)
: {
: Image1->Picture->Bitmap->Canvas->Pen->Color = CColorGrid1->ForegroundColor;
: Image1->Picture->Bitmap->Canvas->Pen->Width = ListBox1->ItemIndex+1;
: Image1->Picture->Bitmap->Canvas->MoveTo(X,Y);
: }
: //---------------------------------------------------------------------------
: 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);
: }
: //---------------------------------------------------------------------------
:
:
: 그림판을 만들었습니다 .
: 기본적으로 펜만 사용가능한데요
: 어떻게하면 도형그릴수 있나요 ㅠㅠ
|