Firemonkey Image Library 2
- Home
- Firemonkey Image Library 2
Browse:
Firemonkey Image Library 2
Først: Det hele starter i Hovedformen, «TForm1», alle menyfunksjoner gjør det, og så jumper programmet i de fleste tilfelle til en funksjon i «DocPage» klassen. Det eneste som gjøres her er å opprette en adressepeker til neste funksjon:
// --------------------- Display Image Properties ---------------
void __fastcall TForm1::menu_PROPERTIES_Click(TObject *Sender) // 19
{
TTabItem *myTabItemPtr;
// Get a pointer to active tab
myTabItemPtr = TabControl1->ActiveTab;
// Type cast to class DocPage and
// let DocPage do the job
((DocPage *) myTabItemPtr)->ImageProperties();
}
De meste av info finnes i bitmap’en, «TBitmap», og hvordan du henter opp denne er egentlig forklart i dokumentasjonen fra Embarcadero.
// --------------------------------------------------------------------------
// Image Properties
// --------------------------------------------------------------------------
void __fastcall DocPage::ImageProperties()
{
try
{
TForm6 *dlgProperties = new TForm6(Application);
dlgProperties->Image1->Bitmap = Image1->Bitmap;
dlgProperties->Caption = _T("Image Properties");
// Pixelformat
TPixelFormat myPixelformat = Image1->Bitmap->PixelFormat;
UnicodeString strPixelformat(PixelFormatToString(myPixelformat));
dlgProperties->Edit1->Text = strPixelformat;
// Bitmap Scale
float BitmapScale = Image1->Bitmap->BitmapScale;
UnicodeString strBitmapScale(BitmapScale);
dlgProperties->Edit2->Text = strBitmapScale;
// Bytes per line
int BytesPerLine = Image1->Bitmap->BytesPerLine;
UnicodeString strBytesPerLine(BytesPerLine);
dlgProperties->Edit3->Text = strBytesPerLine;
// Bytes per pixel
int BytesPerPixel = Image1->Bitmap->BytesPerPixel;
UnicodeString strBytesPerPixel(BytesPerPixel);
dlgProperties->Edit4->Text = strBytesPerPixel;
// Bitmap Height
int Height = Image1->Bitmap->Height;
UnicodeString strHeight(Height);
dlgProperties->Edit5->Text = strHeight;
// Bitmap Width
int Width = Image1->Bitmap->Width;
UnicodeString strWidth(Width);
dlgProperties->Edit6->Text = strWidth;
// -----------------------------------------------------------------
// DisplayCount
iDisplayCount = Screen->DisplayCount;
UnicodeString strDisplayCount(iDisplayCount);
dlgProperties->Edit7->Text = strDisplayCount;
// Desktop Width i pixels (might be for instance dual screen)
iDesktopWidthInPixels = Screen->DesktopWidth;
UnicodeString strDesktopWidth(iDesktopWidthInPixels);
dlgProperties->Edit8->Text = strDesktopWidth;
// Desktop Height i pixels
iDesktopHeightInPixels = Screen->DesktopHeight;
UnicodeString strDesktopHeight(iDesktopHeightInPixels);
dlgProperties->Edit9->Text = strDesktopHeight;
// Screen Width in pixels
iScreenWidthInPixels = Screen->Width;
UnicodeString strScreenWidth(iScreenWidthInPixels);
dlgProperties->Edit10->Text = strScreenWidth;
// Screen Height in pixels
iScreenHeightInPixels = Screen->Height;
UnicodeString strScreenHeight(iScreenHeightInPixels);
dlgProperties->Edit11->Text = strScreenHeight;
// Work area
iWorkAreaWidthInPixels = Screen->WorkAreaWidth;
UnicodeString strWorkAreaWidth(iWorkAreaWidthInPixels);
dlgProperties->Edit12->Text = strWorkAreaWidth;
iWorkAreaHeightInPixels = Screen->WorkAreaHeight;
UnicodeString strWorkAreaHeight(iWorkAreaHeightInPixels);
dlgProperties->Edit13->Text = strWorkAreaHeight;
// Junior school math: a**2 + b**2 = c**2
iScreenSizeInPixels = sqrt(iScreenWidthInPixels*iScreenWidthInPixels + iScreenHeightInPixels*iScreenHeightInPixels);
UnicodeString strpixsize(iScreenSizeInPixels);
dlgProperties->Edit14->Text = strpixsize;
// Guessing 27" monitor as a starter
iScreenPPI = iScreenSizeInPixels / 27;
dlgProperties->Edit15->Text = iScreenPPI;
//UnicodeString strii(17);
dlgProperties->ComboBox1->Items->Add( 15);
dlgProperties->ComboBox1->Items->Add( 17);
dlgProperties->ComboBox1->Items->Add( 19);
dlgProperties->ComboBox1->Items->Add( 20);
dlgProperties->ComboBox1->Items->Add( 22);
dlgProperties->ComboBox1->Items->Add( 24);
dlgProperties->ComboBox1->Items->Add( 27);
dlgProperties->ComboBox1->Items->Add( 28);
dlgProperties->ComboBox1->Items->Add( 32);
dlgProperties->ComboBox1->Items->Add( 34);
dlgProperties->ComboBox1->Items->Add( 35);
dlgProperties->ComboBox1->Items->Add( 43);
dlgProperties->ComboBox1->Items->Add( 49);
dlgProperties->ComboBox1->ItemIndex = 6;
dlgProperties->ShowModal();
if( dlgProperties -> iretState == 1 ) {
//
}
dlgProperties->DisposeOf();
}
catch(...)
{
ShowMessage("Image properties did not succeed");
}
}
Det som ligger av kode i selve dialogboksen, er å foreta en beregning hver gang du endrer skjermstørrelse. Da beregnes verdien av pixels/inch.
//---------------------------------------------------------------------------
void __fastcall TForm6::OnComboBoxChange(TObject *Sender)
{
UnicodeString strSelected = ComboBox1->Selected->Text;
int isize = strSelected.ToInt();
UnicodeString scrSize = Edit14->Text;
int iscrSize = scrSize.ToInt();
int iPixPerInch = round(iscrSize / isize);
Edit15->Text = iPixPerInch;
}
Innleggsnavigasjon
Kategorier
Stikkord
3d
Acronis backup
Android Studio
Backup
Bildeformater
Box Blur
c++ builder
c++builder
captains yacht
Codecs
code samples
Compiler
Delphi
Eksempler
Embarcadero
Firemonkey
Firemonkey Image Library
gamlisen
Gamlisens Fotobox
koding
lightwave
Linux
OpenSuse
plugins
programmering
programmering verktøy
QT
Rad Studio
Raid
Recovery
Rendering
Sharkoon
Startrek Voyager
SUSE
Ubuntu
Ubuntu Studio
usb2.0 og 3.0 harddisk
Verktøy
Windows 10
wordpress