Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 12-31-2016, 07:51 AM
robert robert is offline
Senior Member
 
Join Date: Sep 2014
Posts: 366
Default PNG to BMP

I have PNG Image which I need to convert and save it as bmp . I am using D7
  #2  
Old 12-31-2016, 03:33 PM
GeoWink GeoWink is offline
Senior Member
 
Join Date: Jan 2001
Posts: 878
Default

png to bmp using Delphi -- Google is your friend

George
  #3  
Old 01-01-2017, 06:33 AM
robert robert is offline
Senior Member
 
Join Date: Sep 2014
Posts: 366
Default

Quote:
Originally Posted by GeoWink View Post
png to bmp using Delphi -- Google is your friend

George
I already searched with my friend but I never got any appropriate solution for this.
  #4  
Old 01-01-2017, 08:01 PM
GeoWink GeoWink is offline
Senior Member
 
Join Date: Jan 2001
Posts: 878
Default

If all you need to do is convert a PNG to BMP then got to

http://www.easy2convert.com/png2bmp/

I downloaded the exe and it works nicely.

Is this all you need to do because it sure works well.

George
  #5  
Old 01-02-2017, 03:40 AM
robert robert is offline
Senior Member
 
Join Date: Sep 2014
Posts: 366
Default

Quote:
Originally Posted by GeoWink View Post
If all you need to do is convert a PNG to BMP then got to

http://www.easy2convert.com/png2bmp/

I downloaded the exe and it works nicely.

Is this all you need to do because it sure works well.

George
Oh No. I do not need to use any third party exe to do this I need this to be done in Delphi.
  #6  
Old 01-02-2017, 06:25 AM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 157
Default

D7 could not work with PNG images natively, but you can download PNGImage (TPNGObject) from here, create a package and install it in the IDE. Make sure you add the directory with the source code and the obj directory to D7's library paths. (you can choose not to add the package to the IDE, just add the *.pas files to your program's source directory and add the files to your application.
Code:
uses ..., PNGImage;//make sure you add PNGImage to your uses clause

type

TForm1 = class(TForm)
  ...
private
  procedure ConvertPNGtoBMP(const PNGFileName, BMPSaveToFileName: String);//add a method to handle the converstion
  ...
end;

procedure TForm1.ConvertPNGtoBMP(const PNGFileName, BMPSaveToFileName: String);
var
  PNGImage: TPNGObject;
  BitMap: TBitMap;
begin
  BitMap := TBitMap.Create;
  try
    PNGImage := TPNGObject.Create;
    try
      PNGImage.LoadFromFile(PNGFileName);
      BitMap.Assign(PNGImage);
      BitMap.SaveToFile(BMPSavetoFileName);
    finally
      PNGImage.Free;
    end;
  finally
    BitMap.Free;
  end;
end;
usage
Code:
procedure TForm1.ConvertBitBtnClick(Sender: TObject);
var 
  PNGFile: String;
  BMPFile: String;
begin
  PNGFile := 'c:\path\to\your\png\file.png';
  BMPFile := 'c:\path\to\where\you\want\to\save\bitmap.bmp';
  ConvertPNGtoBMP(PNGFile, BMPFile);
end;
  #7  
Old 01-03-2017, 01:43 PM
robert robert is offline
Senior Member
 
Join Date: Sep 2014
Posts: 366
Default

Thanks a lot always helping.
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:18 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.