rendered paste body//---------------------------------------------------------------------------#include <vcl.h>#pragma hdrstop#include "Unit1.h"#include "Unit2.h"//---------------------------------------------------------------------------#pragma package(smart_init)#pragma resource "*.dfm"TForm1 *Form1;int szer_we, wys_we;//---------------------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner){}//---------------------------------------------------------------------------//---------------------------------------------------------------------------void __fastcall TForm1::Otwrz1Click(TObject *Sender){ if(OpenPictureDialog1->Execute()) { Image1->Picture->Bitmap->LoadFromFile(OpenPictureDialog1->FileName); szer_we = Image1->Picture->Bitmap->Width; wys_we = Image1->Picture->Bitmap->Height; Image1->Picture->Bitmap->PixelFormat=pf32bit; Form2->Image1->Picture->Bitmap->PixelFormat=pf32bit; Image1->Width = szer_we; Image1->Height = wys_we; }}//---------------------------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender){ Form2->Show(); Form2->Width = Edit1->Text.ToInt(); Form2->Height = Edit2->Text.ToInt(); Form2->Image1->Width = Edit1->Text.ToInt(); Form2->Image1->Height = Edit2->Text.ToInt(); Form2->Image1->Picture->Bitmap->Width = Edit1->Text.ToInt(); Form2->Image1->Picture->Bitmap->Height = Edit2->Text.ToInt(); int szer_wy, wys_wy; float wsp_x, wsp_y; int r,g,b; szer_wy = Edit1->Text.ToInt(); wys_wy = Edit2->Text.ToInt(); wsp_x = float(szer_wy)/float(szer_we) ; wsp_y = float(wys_wy)/float(wys_we) ; Form1->Memo1->Clear(); Form1->Memo1->Lines->Add(("szer_we = ")+IntToStr(szer_we)); Form1->Memo1->Lines->Add(("wys_we = ")+IntToStr(wys_we)); Form1->Memo1->Lines->Add(("szer_wy = ")+IntToStr(szer_wy)); Form1->Memo1->Lines->Add(("wys_wy = ")+IntToStr(wys_wy)); Form1->Memo1->Lines->Add(("wsp_x = ")+FloatToStr(wsp_x)); Form1->Memo1->Lines->Add(("wsp_y = ")+FloatToStr(wsp_y)); int tx, ty, p1,p2,p3,p4,P1R,P1G,P1B,P2R,P2G,P2B,P3R,P3G,P3B,P4R,P4G,P4B,SR,SG,SB; float qx,qy, dx, dy, S1R,S1G,S1B,S2R,S2G,S2B; for(int y=1 ; y<wys_wy-2; y++) { for(int x=1,i=1; x<szer_wy-2 && i<wys_we-2; x++,i++) { RGBQUAD * wiersz_we1 = (RGBQUAD *) Image1->Picture->Bitmap->ScanLine[i]; RGBQUAD * wiersz_we2 = (RGBQUAD *) Image1->Picture->Bitmap->ScanLine[i+1]; RGBQUAD * wiersz_wy = (RGBQUAD *) Form2->Image1->Picture->Bitmap->ScanLine[y]; qx = x/wsp_x; // otoczenie w obrazie we qy = y/wsp_y; tx = qx; // czesc calkowita qx ty = qy; dx = qx - tx; // czesc ulamkowa z qx dy = qy - ty; p1 = tx; p2 = tx+1; p3 = tx; p4 = tx+1; P1R = wiersz_we1[p1].rgbRed; P1G = wiersz_we1[p1].rgbGreen; P1B = wiersz_we1[p1].rgbBlue; P2R = wiersz_we1[p2].rgbRed; P2G = wiersz_we1[p2].rgbGreen; P2B = wiersz_we1[p2].rgbBlue; P3R = wiersz_we2[p3].rgbRed; P3G = wiersz_we2[p3].rgbGreen; P3B = wiersz_we2[p3].rgbBlue; P4R = wiersz_we2[p4].rgbRed; P4G = wiersz_we2[p4].rgbGreen; P4B = wiersz_we2[p4].rgbBlue; S1R = P1R+(P2R-P1R)* dx; S1G = P1G+(P2G-P2G)* dx; S1B = P1B+(P2B-P2B)* dx; S2R = P3R+(P4R-P3R)* dx; S2G = P3G+(P4G-P3G)* dx; S2B = P3B+(P4B-P3B)* dx; SR = S1R + (S2R-S1R)* dy; SG = S1G + (S2G-S1G)* dy; SB = S1B + (S2B-S1B)* dy; wiersz_wy[y].rgbRed = (BYTE) SR; wiersz_wy[y].rgbGreen = (BYTE) SG; wiersz_wy[y].rgbBlue = (BYTE) SB; i++; } } Form1->Memo1->Lines->Add(("qx = ")+FloatToStr(qx)); Form1->Memo1->Lines->Add(("qy = ")+FloatToStr(qy)); Form1->Memo1->Lines->Add(("tx = ")+FloatToStr(tx)); Form1->Memo1->Lines->Add(("ty = ")+FloatToStr(ty)); Form1->Memo1->Lines->Add(("dx = ")+FloatToStr(dx)); Form1->Memo1->Lines->Add(("dy = ")+FloatToStr(dy)); Form1->Memo1->Lines->Add(("P1R = ")+IntToStr(P1R)); Form1->Memo1->Lines->Add(("P1G = ")+IntToStr(P1G)); Form1->Memo1->Lines->Add(("P1B = ")+IntToStr(P1B)); Form1->Memo1->Lines->Add(("P2R = ")+IntToStr(P2R)); Form1->Memo1->Lines->Add(("P2G = ")+IntToStr(P2G)); Form1->Memo1->Lines->Add(("P2B = ")+IntToStr(P2B)); Form1->Memo1->Lines->Add(("P3R = ")+IntToStr(P3R)); Form1->Memo1->Lines->Add(("P3G = ")+IntToStr(P3G)); Form1->Memo1->Lines->Add(("P3B = ")+IntToStr(P3B)); Form1->Memo1->Lines->Add(("P4R = ")+IntToStr(P4R)); Form1->Memo1->Lines->Add(("P4G = ")+IntToStr(P4G)); Form1->Memo1->Lines->Add(("P4B = ")+IntToStr(P4B)); Form1->Memo1->Lines->Add(("S1R = ")+FloatToStr(S1R)); Form1->Memo1->Lines->Add(("S1G = ")+FloatToStr(S1G)); Form1->Memo1->Lines->Add(("S1B = ")+FloatToStr(S1B)); Form1->Memo1->Lines->Add(("S2R = ")+FloatToStr(S2R)); Form1->Memo1->Lines->Add(("S2G = ")+FloatToStr(S2G)); Form1->Memo1->Lines->Add(("S2B = ")+FloatToStr(S2B)); Form1->Memo1->Lines->Add(("SR = ")+IntToStr(SR)); Form1->Memo1->Lines->Add(("SG = ")+IntToStr(SG)); Form1->Memo1->Lines->Add(("SB = ")+IntToStr(SB)); Form2->Image1->Repaint();}//---------------------------------------------------------------------------void __fastcall TForm1::Zapisz1Click(TObject *Sender){ if(SavePictureDialog1->Execute()) { Form2->Image1->Picture->Bitmap->PixelFormat=pf24bit; Form2->Image1->Picture->Bitmap->SaveToFile(SavePictureDialog1->FileName); Form2->Image1->Picture->Bitmap->PixelFormat=pf32bit; }}//---------------------------------------------------------------------------/* for(int y=1; y<wys_or-2; y++) { RGBQUAD * wiersz_or = (RGBQUAD *) Image1->Picture->Bitmap->ScanLine[y]; RGBQUAD * wiersz_ko = (RGBQUAD *) Form2->Image1->Picture->Bitmap->ScanLine[y]; for(int x=1; x<szer_or-2; x++) { r = wiersz_or[x].rgbRed; g = wiersz_or[x].rgbGreen; b = wiersz_or[x].rgbBlue; r = 255 - r; g = 255 - g; b = 255 - b; wiersz_ko[x].rgbRed = (BYTE) r; wiersz_ko[x].rgbGreen = (BYTE) g; wiersz_ko[x].rgbBlue = (BYTE) b; } r4 = wiersz_we2[p2x].rgbRed ; g1 = wiersz_we1[p1x].rgbGreen ; g2 = wiersz_we1[p2x].rgbGreen ; g3 = wiersz_we2[p1x].rgbGreen ; g4 = wiersz_we2[p2x].rgbGreen ; b1 = wiersz_we1[p1x].rgbBlue ; wiersz_wy[x].rgbRed = (BYTE) Sr; wiersz_wy[x].rgbGreen = (BYTE) Sg; wiersz_wy[x].rgbBlue = (BYTE) Sb; //RGBQUAD * wiersz_we1 = (RGBQUAD *) Image1->Picture->Bitmap->ScanLine[x]; //RGBQUAD * wiersz_we2 = (RGBQUAD *) Image1->Picture->Bitmap->ScanLine[x+1]; //RGBQUAD * wiersz_wy = (RGBQUAD *) Form2->Image1->Picture->Bitmap->ScanLine[y]; } */