Jump to content

Recommended Posts

Posted

I need to show image seperately when user selects an item from grid. Image element is outside grid.

I do not want to use TUniDBImage since it will be connected to datasource and will select first image by default. 

Posted
22 minutes ago, Gauravg said:

I need to show image seperately when user selects an item from grid. Image element is outside grid.

Hello,

procedure TMainForm.UniDBGrid1SelectionChange(Sender: TObject);
begin

end;

UniDBGrid.OnSelectionChange ?

Posted
2 minutes ago, Sherzod said:

Hello,


procedure TMainForm.UniDBGrid1SelectionChange(Sender: TObject);
begin

end;

UniDBGrid.OnSelectionChange ?

Hello Sherzod,

I know it has to be done either on cellclicked or selectionchange of grid. To add image normally to an image control we specify UniImage.Picture.LoadFromFile(FolderPath+'images\'+IntToStr(adr)+'.jpg').

I want to display image which is in variant variable. I want to know which prooerty of image control i need to use to set image from variant type.

Untitled.png

Posted
14 minutes ago, Gauravg said:

I want to display image which is in variant variable. I want to know which prooerty of image control i need to use to set image from variant type.

Hello,

Please clarify, I do not understand your case.

Posted
Just now, Sherzod said:

Hello,

Please clarify, I do not understand your case.

Hello,

My image is in variant type variable. How to display in image control?

Posted
10 minutes ago, Gauravg said:

Hello,

My image is in variant type variable. How to display in image control?

What kind of variable (jpeg, bmp, png) or  other image files formats ?

Posted

"UniImage.Picture.LoadFromFile(FolderPath+'images\'+IntToStr(adr)+'.jpg')."

I think Your code is useless if you use jpeg or png formats, You better draw in uniImage control Bitmap from file

 

Posted
5 minutes ago, irigsoft said:

What kind of variable (jpeg, bmp, png) or  other image files formats ?

Hello, 

oImage: variant;
oImage:=DSetObject.FieldByName('Pic').AsVariant;
UniImage1.Picture := oImage;//which property of control need to be used to set image

Thank you

Posted
Just now, Gauravg said:

Hello, 

oImage: variant;
oImage:=DSetObject.FieldByName('Pic').AsVariant;
UniImage1.Picture := oImage;//which property of control need to be used to set image

Thank you

I use it by this way to show/draw image in grid:

1. I save images in database, and show it in uniDBGrid when draw Grid

if (Sender As TDBGrid).DataSource.DataSet.RecNo >= 0 then begin
    (SENDER AS TDBGrid).Canvas.FillRect(Rect);
    R := Rect;
    R.Right := R.Left + Trunc((R.Right - R.Left) );
    if (Column.Field is TBlobField)
    AND (Column.Width > 0)
    then begin
      TRY
        bmpImage := tBitmap.Create;
        bmpStream := TMemoryStream.Create;

        //load from datasource

//LoadFromBlobField (Column.Field,bmpStream);

      //load from file

bmpStream.loadFromFile ('Youpath');
        bmpStream.Position := 0;
        bmpImage.LoadFromStream (bmpStream);
        bmpImage.Assign(ResizeBmp (bmpImage,Column.Width,Column.Width));
        IF THackDBGrid(Sender).DefaultRowHeight <> Column.Width then
            THackDBGrid(Sender).DefaultRowHeight := Column.Width;
        THackDBGrid (Sender).RowHeights [0] := THackDBGrid (Sender).Canvas.TextHeight('Wg') + 4;
        (Sender As TDBGrid).Canvas.StretchDraw (R, bmpImage);

        (SENDER AS TDBGrid).Canvas.Brush.Style := bsClear;
 

      FINALLY
        bmpStream.Free;
        bmpImage.Free;
      END;
    end;

end;

You can use this to draw bitmap object of uniImage.Picture.Bitmap

Posted

function LoadFromBlobField(const AField: TField; const Stream: TStream): boolean;
var
  ResultStr: string;
  PResultStr: PChar;
begin
  Result := false;
  if (Assigned(AField)) and (Assigned(Stream)) then begin
    try
      ResultStr := AField.Value;
      PResultStr := PChar(ResultStr);
      Stream.Write(PResultStr^, Length(ResultStr));
      Stream.Seek(0,0);
      Result := true;
    except
    end;
  end;
end;

 

I think AField can be a variant type or just be used to apply the value of the field to the image

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...