Jump to content

Background of picture in UniDBGRid


artem_niko

Recommended Posts

Good afternoon!

For some reason, when icons are found in a UniDBGrid column, the background of the icon is black instead of transparent. I am using icon format:

image.png.07de31c430ac7f18bd79af4ba8bce1f7.png
What modules should be added so that the icons do not have a black background?

My uses:

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, FireDAC.Phys.FBDef,
  FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf,
  FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async,
  FireDAC.Phys, FireDAC.Phys.FB, FireDAC.VCLUI.Wait, FireDAC.Stan.Param,
  FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, uniButton, uniBitBtn,
  UniFSButton, uniPanel, uniGUIClasses, uniBasicGrid, uniDBGrid, System.Actions,
  Vcl.ActnList, uniMainMenu, uniSplitter, FireDAC.Comp.Client, Data.DB,
  uniGUIBaseClasses, uniImageList, FireDAC.Comp.DataSet, FireDAC.Phys.IBBase,
  uniPageControl, Vcl.Controls, Vcl.Forms, jpeg, pngimage, System.Math,
  uniGUITypes, uniGUIAbstractClasses, System.IniFiles, Soap.EncdDecd,
  uniGUIFrame, System.TypInfo, uniLabel, uniCheckBox, uniDBNavigator, uniEdit,
  uniGUIForm, uniTimer, UniFSiGrowl, uniImage, uniWidgets, uniDBEdit,
  IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient,
  IdSMTPBase, IdSMTP, IdMessage, IdBaseComponent, IdComponent, IdIOHandler,
  IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdHashMessageDigest,
  uniMenuButton, UniFSMenuButton, uniHTMLFrame, UniFSGoogleChart, uniRadioButton,
  uniStringGrid, uniChart, uniMultiItem, uniListBox, uniDateTimePicker,
  System.DateUtils, UniFSToggle, uniSpinEdit, uniComboBox;

 

Link to comment
Share on other sites

  • 6 months later...
On 5/21/2022 at 6:59 PM, artem_niko said:

Good afternoon!

For some reason, when icons are found in a UniDBGrid column, the background of the icon is black instead of transparent. I am using icon format:

image.png.07de31c430ac7f18bd79af4ba8bce1f7.png
What modules should be added so that the icons do not have a black background?

My uses:

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, FireDAC.Phys.FBDef,
  FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf,
  FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async,
  FireDAC.Phys, FireDAC.Phys.FB, FireDAC.VCLUI.Wait, FireDAC.Stan.Param,
  FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, uniButton, uniBitBtn,
  UniFSButton, uniPanel, uniGUIClasses, uniBasicGrid, uniDBGrid, System.Actions,
  Vcl.ActnList, uniMainMenu, uniSplitter, FireDAC.Comp.Client, Data.DB,
  uniGUIBaseClasses, uniImageList, FireDAC.Comp.DataSet, FireDAC.Phys.IBBase,
  uniPageControl, Vcl.Controls, Vcl.Forms, jpeg, pngimage, System.Math,
  uniGUITypes, uniGUIAbstractClasses, System.IniFiles, Soap.EncdDecd,
  uniGUIFrame, System.TypInfo, uniLabel, uniCheckBox, uniDBNavigator, uniEdit,
  uniGUIForm, uniTimer, UniFSiGrowl, uniImage, uniWidgets, uniDBEdit,
  IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient,
  IdSMTPBase, IdSMTP, IdMessage, IdBaseComponent, IdComponent, IdIOHandler,
  IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdHashMessageDigest,
  uniMenuButton, UniFSMenuButton, uniHTMLFrame, UniFSGoogleChart, uniRadioButton,
  uniStringGrid, uniChart, uniMultiItem, uniListBox, uniDateTimePicker,
  System.DateUtils, UniFSToggle, uniSpinEdit, uniComboBox;

 

Any idea?

Link to comment
Share on other sites

2 minutes ago, Sherzod said:

Testcase?

Yes, as it were, what an example... I just added a picture display, and it's with a black background. Actually, my question does not mean "how to do it", but maybe some module needs to be connected that supports PNG files, I asked about it. Well, for example, in standard VCL, there is a PNGImage module there.

Link to comment
Share on other sites

7 minutes ago, Sherzod said:

In what way?

Like this:

procedure TUniFrame1.UniDBGrid1FieldImage(
  const Column: TUniDBGridColumn; const AField: TField; var OutImage: TGraphic;
  var DoNotDispose: Boolean; var ATransparent: TUniTransparentOption);
begin
  if SameText(AField.FieldName, 'MyField') then
  begin
    DoNotDispose:=True;
    if AField.AsInteger = 0 then OutImage:=UniImage1.Picture.Graphic
    else
    if AField.AsInteger = 1 then OutImage:=UniImage2.Picture.Graphic;
  end;
end;

 

Link to comment
Share on other sites

Well, yes.

  ...
  else if SameText(AField.FieldName, 'gender') then
  begin
    DoNotDispose := True; // we provide an static image so do not free it.
    if AField.AsString = 'male' then
      OutImage := UniImage1.Picture.Graphic
    else if AField.AsString = 'female' then
      OutImage := UniImage3.Picture.Graphic;
  end;

 

  • Like 1
Link to comment
Share on other sites

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...