Solved

Array of TBitmap

Posted on 2004-09-24
3
1,023 Views
Last Modified: 2008-02-01
Hi!

I have a TBitmap array with some BMPs; The problem is to access these BMPs (I need to show then in TImage component), because it shows blank.

Can anybody help please?

Thanx.
0
Comment
Question by:nany
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
esoftbg earned 250 total points
ID: 12145144
unit Unit1_Q_21144011;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, ExtDlgs, Buttons, Spin, Tabs;

type
  TForm1 = class(TForm)
    SpeedButton1: TSpeedButton;
    OpenPicDlg: TOpenPictureDialog;
    ImgLoad: TImage;
    ImgArr: TImage;
    Scroller: TScroller;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure ScrollerClick(Sender: TObject);
  private   { Private declarations }
    BMPArr:   array of TBitmap;
  public    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  I:      Integer;
begin
  if OpenPicDlg.Execute then
  begin
    I := Length(BMPArr);
    SetLength(BMPArr, I+1);
    BMPArr[I] := TBitmap.Create;
    BMPArr[I].LoadFromFile(OpenPicDlg.FileName);
    ImgLoad.Picture.Bitmap.Assign(BMPArr[I]);
    if (I=0) then
      ImgArr.Picture.Bitmap.Assign(BMPArr[I]);
    Scroller.Max := I;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  SetLength(BMPArr, 0);
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  I:      Integer;
begin
  try
    for I := 0 to Length(BMPArr)-1 do
      BMPArr[I].Free;
  finally
    SetLength(BMPArr, 0);
  end;
end;

procedure TForm1.ScrollerClick(Sender: TObject);
var
  I:      Integer;
begin
  I := Scroller.Position;
  ImgArr.Picture.Bitmap.Assign(BMPArr[I]);
end;

end.
0
 

Author Comment

by:nany
ID: 12145406
thanks esoftbg!
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12145536
nany, you are welcome !
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to fill array with TArray.Create? 14 90
Intraweb download file link ? 1 134
Delphi: Connect to running MS Outlook 4 87
how to change, disabled button color FMX ? 1 33
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question