📄 unit3.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit3.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::FormCreate(TObject *Sender)
{
register int x,y;
register int Left,Right;
bool FlagLeft;
HRGN tepRgn,WndRgn;
Image1->Picture->LoadFromFile(".\\rose.bmp");
Width=Image1->Width;
Height=Image1->Height;
WndRgn=CreateRectRgn(0,0,Width,Height);
for(y=0;y<Height;y++)
{
FlagLeft=false;
for(x=0;x<Width;x++)
{
//发现了线段左边的第一个白点
if(Image1->Canvas->Pixels[x][y]==clWhite&&FlagLeft==false)
{
Left=x;
FlagLeft=true;
}
//发现了线段右边的第一个非白点
else if(Image1->Canvas->Pixels[x][y]!=clWhite&&FlagLeft==true)
{
Right=x;
tepRgn=CreateRectRgn(Left,y,Right,y+1);
CombineRgn(WndRgn,WndRgn,tepRgn,RGN_XOR);
DeleteObject(tepRgn);
FlagLeft=false;
}
}
//处理图像右边的白色区域
if(FlagLeft==true&&x>=Width)
{
tepRgn=CreateRectRgn(Left,y,x,y+1);
CombineRgn(WndRgn,WndRgn,tepRgn,RGN_XOR);
DeleteObject(tepRgn);
}
}
SetWindowRgn(Handle,WndRgn,true);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -