Solved

Array of TBitmap

Posted on 2004-09-24
3
1,028 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 106
Run video youtube webbrowse 10 74
Dev express lookupcombo 3 47
Is there any TOOL for creating database *.CDS[ClientDataSet] ,*.FDS,*.FDB,*.ADB? 6 60
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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