Forum > Databases

DBGRID not responsive when I load pics from db into column cells

(1/1)

hamacker:
Hi guys,
I have a DBGrid that show me a table with blob images where only '.jpg' and '.bmp' in 1024x1024px are acceptable.
The images are faces pictures stretched to 64x64 in dbgrid cell, my problem is that my code bellow is fast to show in dbgrid, but not responsive to navigate when I click or move up/down, need to wait each move.
The code is:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  db_tmpfoto:TDBImage;  fixRect : TRect;  bmpWidth : integer;begin  if Sender is TDBGrid then  begin    fixRect := Rect;    with TDBGrid(Sender) do    begin      (...)      fixRect := Rect;       if Column.Index=0 then  // pic in column index 0      begin        Canvas.FillRect(Rect);         db_tmpfoto:=TDBImage.Create(nil);        try          db_tmpfoto.Datasource:=DS_Qry_Pesqusia;          db_tmpfoto.DataField:='foto';          bmpWidth := (Rect.Bottom - Rect.Top);          fixRect.Right := Rect.Left + bmpWidth;          Canvas.StretchDraw(fixRect,db_tmpfoto.Picture.Bitmap);        finally          db_tmpfoto.free;        end;      end;    end;  end;
It´s load well but so, so slow to navigate, it´s not responsive then I try other method(winner method in my opnion), load all images from db into imagelist and draw in oncolumndrawcell:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var  MyEffect:TGraphicsDrawEffect; // units   ImgList, GraphTypebegin  if Sender is TDBGrid then  begin    with TDBGrid(Sender) do    begin      MyEffect:=gdeShadowed;      if gdRowHighlight in State then      begin        MyEffect:=gdeHighlighted;      end;      if Column.Index=0 then  // foto na coluna 0      begin        Canvas.FillRect(Rect); // limpando a celula com rect vazio        i:=dmPrincipal.Colaboradores_Pics.IndexOf(Datasource.Dataset.Fieldbyname('nome_completo').AsString);        if (i>=0) and (i<=Pred(dmPrincipal.imgList_Colaboradores.Count)) then        begin          dmPrincipal.imgList_Colaboradores.Draw(              Canvas,              Rect.CenterPoint.x-(dmPrincipal.imgList_EP.Width div 2),              Rect.CenterPoint.y-(dmPrincipal.imgList_EP.Height div 2),              i, // imageindex              MyEffect);  // gdeHighlighted ou gdeShadowed         end;      end;          (...)It´s responsive, it´s fast but I need to wait all images want be loaded before into imagelist using threads.
Before considering method using Imagelist a winner, please, there is a good and fast method to load jpg into a dbgrid cell?

Any help will be wellcome.


Navigation

[0] Message Index

Go to full version