Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Delphi i slike, ideja kako rasporediti slike

[es] :: Pascal / Delphi / Kylix :: Delphi i slike, ideja kako rasporediti slike

[ Pregleda: 2681 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

BGrujic

Član broj: 138931
Poruke: 102
109.93.147.*



Profil

icon Delphi i slike, ideja kako rasporediti slike19.12.2009. u 14:04 - pre 173 meseci
Treba mi ideja kako u Delphiju da na formi prikazem sve male slike na jednoj formi poredjane jedna pored druge u vise redova. Broj slika nije unaprd odredjen i moze da se menja. Slike mogu da se nalaze u jednom folderu a moze i u bazi.
Pozdrav
 
Odgovor na temu

lan-mi
Lukic Milan
Zrenjanin

Član broj: 156359
Poruke: 140
*.dynamic.sbb.rs.

Sajt: https://lanmisoft.com


+1 Profil

icon Re: Delphi i slike, ideja kako rasporediti slike19.12.2009. u 20:43 - pre 173 meseci
http://jvcl.delphi-jedi.org/
U moru free komponenti postoji i ThumbView koja radi isto sto i bilo koji program za pregled slika. U paketu postoji i demo.
Arduino Control Center
 
Odgovor na temu

BGrujic

Član broj: 138931
Poruke: 102
79.101.154.*



Profil

icon Re: Delphi i slike, ideja kako rasporediti slike23.12.2009. u 15:47 - pre 173 meseci
Ustvari treba mi ideja kako napraviti program za skolu da se na formi vide slike svih ucenika iz baze (razliciti broj za razlicita odeljenja). Klikom na sliku da se prikazu podaci o uceniku i ocene.
 
Odgovor na temu

X Files
Vladimir Stefanovic
Pozarevac

SuperModerator
Član broj: 15100
Poruke: 4901
*.dynamic.sbb.rs.

Jabber: xfiles@elitesecurity.org


+638 Profil

icon Re: Delphi i slike, ideja kako rasporediti slike23.12.2009. u 17:44 - pre 173 meseci
Recimo, mozes da postavis jedan TScrollBox na formu i u njemu dinamicki kreiras potreban broj TImage objekata koje punis slikama.

Dinamicko kreiranje mozes staviti u dvostrukoj petlji, da bi lakse mogao da izracunavas poziciju (kao u matrici) gde ces postaviti odgovarajuci TImage. Na istom mestu definises sve Evente koji ti trebaju. Ponekad se ovaj koncept moze modifikovati i sa TPaintBox koga takodje prethodno strpas u TScrollBox.

Evo jedan mali test kod na C++ Builderu. Princip je isti jer je VCL u pitanju

Code:

__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
   DoubleBuffered = true;
   
   Invalidate();
   Repaint();

   for ( int i=0; i<=7; i++ )
      for ( int j=0; j<=7; j++ )
      {

         Image[i][j] = new TImage( ScrollBox1 );
         Image[i][j]->Parent = ScrollBox1;
         Image[i][j]->Width = 463;
         Image[i][j]->Height= 544;
         Image[i][j]->Left = i*463;
         Image[i][j]->Top  = j*544;
         Image[i][j]->Picture->LoadFromFile(ExtractFilePath( ParamStr(0) )+ "\\Z2\\" + IntToStr(j+1) + IntToStr(i+1) + ".jpg" );
         Image[i][j]->OnMouseDown = MyMouseDown;
         Image[i][j]->OnMouseMove = MyMouseMove;
         Image[i][j]->OnMouseUp   = MyMouseUp;
         // ... ostali dogadjaji
      }
}

 
Odgovor na temu

bondja

Član broj: 10286
Poruke: 167
*.procreditbank.rs.



+3 Profil

icon Re: Delphi i slike, ideja kako rasporediti slike28.12.2009. u 13:40 - pre 173 meseci
Napomena: slike sam numerisao prema ID-ovima ljudi iz baze, sto je olaksalo rad.
Npr: ako korisnik ima id= 134, onda je ime njegove slike : 134.jpg

Postavi na formu komponente: TDrawGrid, TFileListBox i ubaci kod:

Code:

unit frmImages;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, Contnrs, StdCtrls, FileCtrl, ExtCtrls;

type
  TfrmImage = class(TForm)
    DrawGrid1: TDrawGrid;
    filesBox: TFileListBox;
  
    procedure FormCreate(Sender: TObject);
    procedure DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure DrawGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
  private
    { Private declarations }
    FImgList: TStringList;
    function LinearIndexOf(Row, Column: integer): integer;
  public
    { Public declarations }
  end;

implementation

{$R *.dfm}

uses Jpeg;

const
  cPicDir = 'Data\Pictures\';

procedure TfrmImage.FormCreate(Sender: TObject);
var
  i: integer;
  sPicFolder: string;
  sFN : string;
  jpg: TJPEGImage;
  bmp: TBitmap;
begin
  DrawGrid1.DefaultDrawing := false;
  filesBox.mask := '*.jpg'; // da ti izlista samo jpg fajlove


  sPicFolder := IncludeTrailingPathDelimiter
     ( IncludeTrailingPathDelimiter( ExtractFilePath( Application.ExeName)) + cPicDir);

  self.filesBox.Directory :=  sPicFolder;
  DrawGrid1.ColCount := 6;
  DrawGrid1.RowCount := 1 + (filesBox.Items.Count div  DrawGrid1.ColCount);


  FimgList := TStringList.Create;
  jpg := TJPEGImage.Create;
  for i:=0 to filesBox.Items.Count-1 do
  begin
    sFN := sPicFolder + filesBox.Items.Strings[i];

    if fileExists(sFN) then
    begin
      jpg.LoadFromFile(sFN);

      bmp := TBitmap.Create;
      bmp.Assign(jpg);

      // ime slike  + slika:
      FImgList.AddObject( filesBox.Items.Strings[i], bmp);
    end;
  end;

  FreeAndNil(jpg);
end;

function TfrmImage.LinearIndexOf (Row, Column : integer) : integer;
begin
  Result := DrawGrid1.ColCount * Row +  Column // Returns the index of the given cell
end;


procedure TfrmImage.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  index : integer;
  bmp: TBitmap;
begin
  // ovo iscrtava slike:
  index := LinearIndexOf(ARow, ACol);

  if (0<=index) and ( index < FImgList.Count) then
  begin
    bmp := TBitmap( FImgList.Objects[index]);
    try
      if assigned( bmp) then
        DrawGrid1.Canvas.StretchDraw(Rect, bmp);
    except

    end;
  end;
end;


procedure TfrmImage.DrawGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
  var CanSelect: Boolean);
var
  index: integer;
  IDValue: integer;
begin
  index := LinearIndexOf(ARow, ACol);

  if (0<=index) and ( index < FImgList.Count) then
  begin
    try
      IDValue := StrToInt(ChangeFileExt( FImgList.Strings[index], ''));

      // iscitas iz baze za dati ID podatke . .  .
    except

    end;
  end;
end;

end.

 
Odgovor na temu

[es] :: Pascal / Delphi / Kylix :: Delphi i slike, ideja kako rasporediti slike

[ Pregleda: 2681 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.