Solved

Array of TBitmap

Posted on 2004-09-24
3
1,033 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 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