To get you started -
Start a new VCL Forms project.
In the IDE, in Design Mode-
1. From the Tool Palette, drop a TImage component onto your Form.
2. Drop a TOpenDialog onto the form.
3. Drop a Button onto the form.
4. Double click on the Button. This wiil create an event handler function stub in your code.
5. Add the code below so it looks like this
- Code: Select all
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(OpenDialog1->Execute())
{
Image1->Picture->LoadFromFile(OpenDialog1->FileName);
}
}
//---------------------------------------------------------------------------
6. Compile and run the program.
When you click the button, a dialog will open, allowing you to browse to where your *.bmp files are located. Select the image you want, and open it.
You can access the graphic elements through the Picture property of TImage. The Bitmap is available with
Image1->Picture->Bitmap. Individual pixel colour values are accessible with
Image1->Picture->Bitmap->Canvas->Pixels [X][Y].
When working with pixels, check out the Bitmap's Scanline property, which provides indexed access to rows of pixels, and is faster than individual pixel access.
There are a considerable number of properties and methods for you to explore - the online Help should provide most answers.
Have fun exploring.
Aris