Results 1 to 2 of 2

Thread: Image bewaren als PNG

  1. #1

    Image bewaren als PNG

    Hallo,

    Ik heb een TImage component waar een picture wordt ingeladen.
    Nu wil ik dit bewaren als een PNG.

    Dit is de code :

    Code:
         
    var PNG: TPNGImage; 
    
    ...
       
      // save image to file
      PNG := TPNGImage.Create;
      try
        PNG.Assign(imgPerson.Picture.Graphic); // ImgPerson is TImage component
        PNG.SaveToFile(image_path + file_name + '.PNG');
      finally
        PNG.Free;
      end;
    Er wordt een PNG bestand aangemaakt. Maar als ik het open zie ik enkel een wit vierkant.

    Enig idee wat ik moet aanpassen om dit te laten werken.

    Alvast bedankt

    Lanikes

  2. #2
    Fornicatorus Formicidae VideoRipper's Avatar
    Join Date
    Mar 2005
    Location
    Vicus Saltus Orientalem
    Posts
    5,708
    Delphi Code:
    1. uses
    2.   PNGImage;
    3.  
    4. var
    5.   oPNG: TPNGImage;
    6.   oBMP: TBitmap;
    7. begin
    8.   oPNG := TPNGImage.Create;
    9.   try
    10.     oBMP := TBitmap.Create;
    11.     try
    12.       oBMP.Assign(imgPerson.Picture.Graphic);
    13.       oPNG.Assign(oBMP);
    14.       oPNG.SaveToFile('C:\Temp\TestImage.png');
    15.     finally
    16.       oBMP.Free;
    17.     end;
    18.   finally
    19.     oPNG.Free;
    20.   end;
    21. end;
    TMemoryLeak.Create(Nil);

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •