How to load/import JPG images into AC?

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #51561
    Support
    Keymaster

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

      #51563
      SzakiLaci
      Participant
        '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? ^_^

        #51564
        Support
        Keymaster
          '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.

          #51567
          CheshireCat
          Participant

            I 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?

            #51568
            Support
            Keymaster
              'CheshireCat' wrote:

              //Save as PNG

              Dest.SaveToFile(FileName);

              No, image will be saved as Bitmap here.

              Png may be extracted from AlphaImageList only.

              #51569
              SzakiLaci
              Participant
                '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:

                PNGdelphi

                … will test it tomorrow 😉

                Cheers

                #51575
                CheshireCat
                Participant
                  '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:

                  #52145
                  SzakiLaci
                  Participant
                    '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:

                    TPNGObject

                    – 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

                    #52165
                    Support
                    Keymaster

                      Hi

                      Reason is easy, TPNGObject does not exists in old versions of Delphi.

                      #52180
                      Marv
                      Participant

                        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.

                        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

                        #52234
                        SzakiLaci
                        Participant
                          '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 ?

                          #52301
                          Support
                          Keymaster

                            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.

                            #52371
                            SzakiLaci
                            Participant
                              '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:

                              #52800
                              SzakiLaci
                              Participant

                                I've found a better solution:

                                Graphics32

                              Viewing 14 posts - 1 through 14 (of 14 total)
                              • You must be logged in to reply to this topic.