📄 unit1.cpp
字号:
//---------------------------------------------------------------------------
#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 TForm1::Button2Click(TObject *Sender)
{
Byte *ptr;
int i,x,y;
Graphics::TBitmap* pb=new Graphics::TBitmap;
try
{
pb->LoadFromFile(".\\Forest.bmp");
pb->PixelFormat=pf24bit;
for(i=0;i<256;i++)
{
for(y=0;y<pb->Height;y++)
{
ptr=(Byte *)pb->ScanLine[y];
for(x=0;x<pb->Width*3;x++)
{
if(ptr[x]>0) ptr[x]=Byte(ptr[x]-1);
}
Application->ProcessMessages();
}
Image1->Canvas->Draw(0,0,pb);
}
}
catch(...)
{
delete pb;
Close();
}
delete pb;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Byte *ptr1;
Byte *ptr2;
int i,x,y;
Graphics::TBitmap* pb1=new Graphics::TBitmap;
Graphics::TBitmap* pb2=new Graphics::TBitmap;
try
{
pb1->LoadFromFile(".\\Forest.bmp");
pb2->LoadFromFile(".\\Forest.bmp");
pb1->PixelFormat=pf24bit;
pb2->PixelFormat=pf24bit;
for(y=0;y<pb2->Height;y++)
{
ptr2=(Byte *)pb2->ScanLine[y];
for(x=0;x<pb2->Width*3;x++)
{
ptr2[x]=0;
}
}
for(i=0;i<256;i++)
{
for(y=0;y<pb2->Height;y++)
{
ptr1=(Byte *)pb1->ScanLine[y];
ptr2=(Byte *)pb2->ScanLine[y];
for(x=0;x<pb2->Width*3;x++)
{
if(ptr2[x]<ptr1[x]) ptr2[x]=Byte(ptr2[x]+1);
}
Application->ProcessMessages();
}
Image1->Canvas->Draw(0,0,pb2);
}
}
catch(...)
{
delete pb1;
delete pb2;
Close();
}
delete pb1;
delete pb2;
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -