Plik cpp Formy7:
KOD cpp: UKRYJ
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit7.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CSPIN"
#pragma resource "*.dfm"
TForm7 *Form7;
//---------------------------------------------------------------------------
__fastcall TForm7::TForm7(TComponent* Owner)
: TForm(Owner)
{
DoubleBuffered = true;
BMP = new Graphics::TBitmap();
img = Form1->Image;
img->Stretch = false;
img->AutoSize = true;
}
//---------------------------------------------------------------------------
Graphics::TBitmap *ConvertImage(TImage *Cimg)
{
Graphics::TBitmap * bmp = new Graphics::TBitmap();
bmp->Width = Cimg->Width;
bmp->Height = Cimg->Height;
bmp->Canvas->Draw( 0, 0, Cimg->Picture->Graphic);
return bmp;
}
//---------------------------------------------------------------------------
void __fastcall TForm7::CSpin1Change(TObject *Sender)
{
try
{
if(ActiveControl == CSpin1)
{
float y = (float)img->Width / ((float)img->Height / (float)CSpin1->Value);
CSpin2->Value = y;
}
}catch(...){;}
}
//---------------------------------------------------------------------------
void __fastcall TForm7::CSpin2Change(TObject *Sender)
{
try
{
if(ActiveControl == CSpin2)
{
float x = (float)img->Height / ((float)img->Width / (float)CSpin2->Value);
CSpin1->Value = x;
}
}catch(...){;}
}
//---------------------------------------------------------------------------
void __fastcall TForm7::BitBtn1Click(TObject *Sender)
{
Image1->Width = CSpin2->Value;
Image1->Height = CSpin1->Value;
Image1->Canvas->CopyMode = cmNotSrcCopy;
Image1->Canvas->StretchDraw(Rect(0, 0, Image1->Width, Image1->Height), Image1->Picture->Bitmap);
Form1->Image->Picture->Assign(Image1->Picture);
Form1->Show();
Form7->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm7::BitBtn2Click(TObject *Sender)
{
Form7->Close();
}
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit7.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "CSPIN"
#pragma resource "*.dfm"
TForm7 *Form7;
//---------------------------------------------------------------------------
__fastcall TForm7::TForm7(TComponent* Owner)
: TForm(Owner)
{
DoubleBuffered = true;
BMP = new Graphics::TBitmap();
img = Form1->Image;
img->Stretch = false;
img->AutoSize = true;
}
//---------------------------------------------------------------------------
Graphics::TBitmap *ConvertImage(TImage *Cimg)
{
Graphics::TBitmap * bmp = new Graphics::TBitmap();
bmp->Width = Cimg->Width;
bmp->Height = Cimg->Height;
bmp->Canvas->Draw( 0, 0, Cimg->Picture->Graphic);
return bmp;
}
//---------------------------------------------------------------------------
void __fastcall TForm7::CSpin1Change(TObject *Sender)
{
try
{
if(ActiveControl == CSpin1)
{
float y = (float)img->Width / ((float)img->Height / (float)CSpin1->Value);
CSpin2->Value = y;
}
}catch(...){;}
}
//---------------------------------------------------------------------------
void __fastcall TForm7::CSpin2Change(TObject *Sender)
{
try
{
if(ActiveControl == CSpin2)
{
float x = (float)img->Height / ((float)img->Width / (float)CSpin2->Value);
CSpin1->Value = x;
}
}catch(...){;}
}
//---------------------------------------------------------------------------
void __fastcall TForm7::BitBtn1Click(TObject *Sender)
{
Image1->Width = CSpin2->Value;
Image1->Height = CSpin1->Value;
Image1->Canvas->CopyMode = cmNotSrcCopy;
Image1->Canvas->StretchDraw(Rect(0, 0, Image1->Width, Image1->Height), Image1->Picture->Bitmap);
Form1->Image->Picture->Assign(Image1->Picture);
Form1->Show();
Form7->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm7::BitBtn2Click(TObject *Sender)
{
Form7->Close();
}
//---------------------------------------------------------------------------
plik nagłówkowy:
KOD cpp: UKRYJ
//---------------------------------------------------------------------------
#ifndef Unit7H
#define Unit7H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "CSPIN.h"
#include <Buttons.hpp>
#include <ExtCtrls.hpp>
#include <Dialogs.hpp>
#include <ExtDlgs.hpp>
#include <JPEG.hpp>
//---------------------------------------------------------------------------
class TForm7 : public TForm
{
__published: // IDE-managed Components
TImage *Image1;
TBitBtn *BitBtn1;
TBitBtn *BitBtn2;
TCSpinEdit *CSpin1;
TCSpinEdit *CSpin2;
void __fastcall CSpin1Change(TObject *Sender);
void __fastcall CSpin2Change(TObject *Sender);
void __fastcall BitBtn1Click(TObject *Sender);
void __fastcall BitBtn2Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm7(TComponent* Owner);
Graphics::TBitmap *BMP;
TImage *img;
};
//---------------------------------------------------------------------------
extern PACKAGE TForm7 *Form7;
//---------------------------------------------------------------------------
#endif
#ifndef Unit7H
#define Unit7H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "CSPIN.h"
#include <Buttons.hpp>
#include <ExtCtrls.hpp>
#include <Dialogs.hpp>
#include <ExtDlgs.hpp>
#include <JPEG.hpp>
//---------------------------------------------------------------------------
class TForm7 : public TForm
{
__published: // IDE-managed Components
TImage *Image1;
TBitBtn *BitBtn1;
TBitBtn *BitBtn2;
TCSpinEdit *CSpin1;
TCSpinEdit *CSpin2;
void __fastcall CSpin1Change(TObject *Sender);
void __fastcall CSpin2Change(TObject *Sender);
void __fastcall BitBtn1Click(TObject *Sender);
void __fastcall BitBtn2Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm7(TComponent* Owner);
Graphics::TBitmap *BMP;
TImage *img;
};
//---------------------------------------------------------------------------
extern PACKAGE TForm7 *Form7;
//---------------------------------------------------------------------------
#endif
plik cpp formy1:
KOD cpp: UKRYJ
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#include "Unit3.h"
#include "Unit4.h"
#include "Unit5.h"
#include "Unit6.h"
#include "Unit7.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
if(OpenPictureDialog1->Execute())
{
Image->Picture->LoadFromFile(OpenPictureDialog1->FileName);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn6Click(TObject *Sender)
{
Form7->BMP->Assign( Image->Picture->Graphic );
Form7->BMP->PixelFormat = pf32bit;
Form7->Image1->Picture->Assign( Form7->BMP );
Form7->CSpin1->Value = Image->Height;
Form7->CSpin2->Value = Image->Width;
Form7->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn9Click(TObject *Sender)
{
SavePictureDialog1->Execute();
Image->Picture->SaveToFile(SavePictureDialog1->FileName);
}
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#include "Unit3.h"
#include "Unit4.h"
#include "Unit5.h"
#include "Unit6.h"
#include "Unit7.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
if(OpenPictureDialog1->Execute())
{
Image->Picture->LoadFromFile(OpenPictureDialog1->FileName);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn6Click(TObject *Sender)
{
Form7->BMP->Assign( Image->Picture->Graphic );
Form7->BMP->PixelFormat = pf32bit;
Form7->Image1->Picture->Assign( Form7->BMP );
Form7->CSpin1->Value = Image->Height;
Form7->CSpin2->Value = Image->Width;
Form7->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn9Click(TObject *Sender)
{
SavePictureDialog1->Execute();
Image->Picture->SaveToFile(SavePictureDialog1->FileName);
}
//---------------------------------------------------------------------------





