Solved

Array of TBitmap

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now