Ignore:
Timestamp:
Dec 8, 2021, 2:29:29 PM (2 years ago)
Author:
chronos
Message:
  • Added: Support for PNG encoded contact photos.
  • Added: Clone button on contact fields toolbar.
  • Added: Show open file dialog on photo click.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.pas

    r50 r54  
    206206  Stream: TMemoryStream;
    207207  JpegImage: TJpegImage;
     208  PngImage: TPortableNetworkGraphic;
    208209begin
    209210  Contact.Fields[cfFullName] := EditFullName.Text;
     
    247248          JpegImage.Free;
    248249        end;
     250      end else
     251      if PhotoProperty.Attributes.IndexOf('PNG') <> -1 then begin
     252        PngImage := TPortableNetworkGraphic.Create;
     253        try
     254          try
     255            PngImage.SetSize(ImagePhoto.Picture.Bitmap.Width, ImagePhoto.Picture.Bitmap.Height);
     256            PngImage.Canvas.Draw(0, 0, ImagePhoto.Picture.Bitmap);
     257            PngImage.SaveToStream(Stream);
     258          except
     259          end;
     260        finally
     261          PngImage.Free;
     262        end;
    249263      end else begin
    250264        try
     
    274288  Photo: string;
    275289  JpegImage: TJpegImage;
     290  PngImage: TPortableNetworkGraphic;
    276291  Stream: TMemoryStream;
    277292  PhotoProperty: TContactProperty;
     
    319334            JpegImage.Free;
    320335          end;
     336        end else
     337        if PhotoProperty.Attributes.IndexOf('PNG') <> -1 then begin
     338          PngImage := TPortableNetworkGraphic.Create;
     339          try
     340            try
     341              PngImage.LoadFromStream(Stream);
     342              with ImagePhoto.Picture.Bitmap do begin
     343                PixelFormat := pf24bit;
     344                SetSize(PngImage.Width, PngImage.Height);
     345                Canvas.Draw(0, 0, PngImage);
     346              end;
     347              ProfilePhotoActive := True;
     348            except
     349              ProfilePhotoActive := False;
     350            end;
     351          finally
     352            PngImage.Free;
     353          end;
    321354        end else begin
    322355          try
Note: See TracChangeset for help on using the changeset viewer.