1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| #include <vcl.h>
#pragma hdrstop
#include "Unitramzi.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClick(TObject *Sender)
{
OpenPictureDialog1->Execute();
Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName);
Image1->Height=Image1->Picture->Height;
Image1->Width=Image1->Picture->Width;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Canvas->Rectangle(300,50,600,300);
Canvas->Pen->Color=clBlue;
Canvas->MoveTo(320,75);
Canvas->LineTo(320,300) ;
Canvas->MoveTo(320,200);
Canvas->LineTo(450,200);
int histo[266];
int i,j;
for(i=0;i<266;i++)
histo[i]=0;
for(i=48;i<Image1->Width+1024;i++)
for(j=8;j<Image1->Height+1024;j++)
histo[Canvas->Pixels[i][j]]++;
for(i=0;i<266;i++)
Canvas->Pen->Color=clBlack;
Canvas->MoveTo(i+320,100);
Canvas->LineTo(i+320,histo[i]+100);
} |
Partager