|
그런데, 근본적으로 박스까지 변하는 문제는 못고쳤네요.
이리저리 고칠려고 하다보니까 여기 계신것 같아서.. :)
같이 풀면 도움이 더 되지 않을까 하구 그냥 올려봅니다..
저도 나중에 꼭 필요한 루틴 같아서 다시 또 만들어보러.. =3=3=3
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int START_X, START_Y;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
// 아무 이미지나 로드. 테스트용
Image1->Picture->LoadFromFile("C:\\Windows\\바람부는 들판.bmp");
Image1->Picture->Bitmap->PixelFormat = pf24bit;
// 깜빡거림 방지
DoubleBuffered = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
{
PrintText(Image1->Canvas, X, Y, "CLICK");
START_X = X;
START_Y = Y;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
{
PrintText(Image1->Canvas, START_X, START_Y, "CLICK");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PrintText(TCanvas *tcCanvas, int itX, int itY, String stText)
{
Graphics::TBitmap *btBitmap = new Graphics::TBitmap;
TCanvas *tcTempCanvas = btBitmap->Canvas;
TRect trSourceRect, trTargetRect;
// 비트맵 초기화
btBitmap->Width = tcCanvas->TextWidth(stText);
btBitmap->Height = tcCanvas->TextHeight(stText);
tcTempCanvas->Font = tcCanvas->Font;
tcTempCanvas->Brush->Color = clBlack;
tcTempCanvas->Brush->Style = bsClear;
trSourceRect = Rect(0, 0, btBitmap->Width, btBitmap->Height);
trTargetRect = Rect(itX, itY, itX + btBitmap->Width, itY + btBitmap->Height);
tcTempCanvas->FillRect(trSourceRect);
tcTempCanvas->TextOut(0, 0, stText);
tcCanvas->CopyMode = cmSrcInvert;
tcCanvas->CopyRect(trTargetRect, tcTempCanvas, trSourceRect);
delete btBitmap;
}
//---------------------------------------------------------------------------
유영인 Cuperido 님이 쓰신 글 :
: Canvas->Brush->Style, Canvas->Brush->Color, Canvas->Font->Color 등을 이리저리 조작해서 원하시는 값을 맞추시면 될것 같습니다.
:
: cuperido
:
: 이운국 님이 쓰신 글 :
: : .
|