- This topic has 14 replies, 4 voices, and was last updated 10 years ago by SzakiLaci.
-
AuthorPosts
-
February 15, 2014 at 11:47 am #36039SzakiLaciParticipant
Hi, 😉
looking for a solution since 2 days…
Because loading a JPG and convert into BMP is OK.
But how do I convert it back to a non-masked PNG that TsImage or TsAlphaImageList can handle?
(Finally I want to save it to a PNG file and load back to stream to upload into a Database. But this is OK.)
Can someone give me a hint how to do that?
February 15, 2014 at 1:03 pm #51561SupportKeymasterIf you have images contained in the TsAlphaImageList component, then you can extract them in original format, because this component keeps images without changes.
Png are stored as Png there.
Saving from Bmp to Png is not implemented in the AlphaControls (only reading).
February 15, 2014 at 1:19 pm #51563SzakiLaciParticipant'Support' wrote:… Saving from Bmp to Png is not implemented in the AlphaControls (only reading).
Thanks for the quick response 🙂
YES, I know it's not directly implemented, that's why I'm trying to get some help please.
Because previously I had many problems about importing PNG images of different types, (auto-alpha converted by Irfanview) I'm afraid if I find a wrong code, it won't work.
How do YOU convert JPG/BMP to PNG dynamically? ^_^
February 15, 2014 at 1:29 pm #51564SupportKeymaster'SzakiLaci' wrote:How do YOU convert JPG/BMP to PNG dynamically? ^_^I not converts images to Png in the package, it's not needed there.
February 15, 2014 at 5:28 pm #51567CheshireCatParticipantI use the following simple procedure for storing bitmaps in files:
Code:uses
PNGImage;procedure SaveToPNG(Source: TBitmap; FileName: String);
var
Dest: TPNGImage;
begin
Dest := TPNGImage.Create;
try
//Assign picture from source
Dest.Assign(Source);
//Save as PNG
Dest.SaveToFile(FileName);
finally
//Release PNG
Dest.Free;
end;
end;Maybe you are looking for something?
February 15, 2014 at 5:59 pm #51568SupportKeymaster'CheshireCat' wrote://Save as PNG
Dest.SaveToFile(FileName);
No, image will be saved as Bitmap here.
Png may be extracted from AlphaImageList only.
February 15, 2014 at 8:15 pm #51569SzakiLaciParticipant'CheshireCat' wrote:I use the following simple procedure for storing bitmaps in files:
uses
PNGImage;
procedure SaveToPNG(Source: TBitmap; FileName: String);
var
Dest: TPNGImage;
…
Maybe you are looking for something?
[/quote]Thanks, but this is only possible up from Delphi2009+
… if it would be so easy, I wouldn't ask 😀
Sadly I'm still using Delphi 7 ! There is no PNGImage unit in that old version.
I've found this:
PNGdelphi
… will test it tomorrow 😉Cheers[code]
uses
PNGImage;
procedure SaveToPNG(Source: TBitmap; FileName: String);
var
Dest: TPNGImage;
…
Maybe you are looking for something?
Thanks, but this is only possible up from Delphi2009+
… if it would be so easy, I wouldn't ask 😀
Sadly I'm still using Delphi 7 ! There is no PNGImage unit in that old version.
I've found this:
… will test it tomorrow 😉
Cheers
February 16, 2014 at 10:25 am #51575CheshireCatParticipant'Support' wrote:No, image will be saved as Bitmap here.
Png may be extracted from AlphaImageList only.
Ok, I understand what you mean, I thought he needs the file only for Upload :blush:
July 9, 2014 at 6:14 pm #52145SzakiLaciParticipant'Support' wrote:Png may be extracted from AlphaImageList only.
Dear Serge,
I still not fully understand, WHY do you use that PNG unit in AC, instead of:
– it is FREE
– can be used to SAVE / convert / reconvert / add info to PNG format
– easy to use
– knows more variants of png compressions (AC can not open some png formats)
– you may choose compression rate/method/speed
– and very WELL documented !!!
Please consider …
Cheers,
Laci
July 12, 2014 at 6:21 am #52165SupportKeymasterHi
Reason is easy, TPNGObject does not exists in old versions of Delphi.
July 13, 2014 at 8:40 am #52180MarvParticipantProbably the most simple and useful class file I've found for handling PNG, GIF, TIF as well as JPEG on the fly is SynGDIPlus.
I load the file in via a TsOpenDialog, extract the extension from the filename, test it for the type
then do whatever in a “Case [variable] Of” statement.
That way I'm positive of what the file format is.
Each supported graphics format has a built in [FormatType].ToBitMap procedure that converts the image, regardless of the supported type, to a bitmap.
From there, you can assign it to your temp BMP object. Paint it to the screen, paint to a form, a control, or whatever.
nice thing is SynGDIPlus is free.
If your going beyond the most standard formats, then you might want to look at the Vampyre Imaging library, or GraphicsEx
July 25, 2014 at 3:13 pm #52234SzakiLaciParticipant'Marv' wrote:Probably the most simple and useful class file I've found for handling PNG, GIF, TIF as well as JPEG on the fly is SynGDIPlus.
…
Thanks for the info !
THIS could be it 🙂 Other libraries, like Vampyre Imaging library, or GraphicsEx are NOT able to SAVE pictures to every format.
But as much as I've red, SynGDIPlus seems to be the one, that can compress images into JPG, PNG formats.
The only problem I have is the license … I do not exactly understand, is it really possible to use in a commercial program for free without sharing the source ?
August 17, 2014 at 2:32 pm #52301SupportKeymasterAlphaControls uses own Png-extractor, which is small, have support of main Png formats and do not required a licensing.
But can't compress and create new Png images.
August 31, 2014 at 12:26 pm #52371SzakiLaciParticipant'Support' wrote:AlphaControls uses own Png-extractor, which is small, have support of main Png formats and do not required a licensing.
But can't compress and create new Png images.
I know it does.
Anyway I've digged deeper to the licensing, and it seems -as long you do not make changes to the SynGDIPlus code- you can use it in your package 😉
If you do not want > could you please create a compiler directive, so someone can exclude YOUR png unit, and redirect AlphaS. to use SynGDIPlus ?
{$DEFINE USE_SYNGDIPLUS} // instead of own PNG unit
THANKS :a3:
November 25, 2014 at 12:17 pm #52800SzakiLaciParticipantI've found a better solution:
-
AuthorPosts
- You must be logged in to reply to this topic.