Get part of an image from TsImage

Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • #52461
    Support
    Keymaster

      Hello

      I not quite understand a question, seems.

      This image is stored in the ImageList?

      Or you want to receive a bitmap which contained in “img1.Picture.Bitmap”?

      #52463
      SzakiLaci
      Participant
        'Support' wrote:

        This image is stored in the ImageList?

        Or you want to receive a bitmap which contained in “img1.Picture.Bitmap”?

        No, it's not stored anywhere. I'm trying to write a kind of “picture editor/cutter/resizer”.

        1. I load a JPG or PNG runtime directly into a TsImage

        (Because it can load many types well, and keep 32bit alpha too)

        2. Than I set borders to cut (and keep a part of the pic)

        3. Than will re-compress as a smaller PNG, and save to a Database.

        Thanks !

        #48844
        Support
        Keymaster

          So, you need to compress a small image into Png? It's not possible with acPNG handler.

          #52519
          SzakiLaci
          Participant
            'Support' wrote:

            So, you need to compress a small image into Png? It's not possible with acPNG handler.

            This was NOT my question!

            (I can compress images with 2 different units, like SynGDIPlus mentioned here… So it's working fine.)

            My question was:

            “How can I copy a part of the original image loaded into TsImage”

            ______________________

            I've tested the problem further, used different units to load the image … (leaving TsImage out)

            and realized it works fine, if I define the destination Bitmap as 24bit. The problem starts, if I use pf32bit, or the predefined CreateBmp32(ew, eh); function.

            Seems for me like Delphi 7 CopyRect is buggy, if trying to work with alpha-channel bitmaps.

            #52520
            SzakiLaci
            Participant
              'SzakiLaci' wrote:

              Seems for me like Delphi 7 CopyRect is buggy, if trying to work with alpha-channel bitmaps.

              .. OR :

              maybe copy works fine, BUT when I load the 32bit alpha-channeled Bitmap back to the TsImage >> it can not show ?

              (I have red, that TImage can not handle 32bit bitmaps. Can TsImage do that?)

              But newer Delphi should be able to handle it… :

              Link…

              So I'm officially confused now :wacko:

              #52523
              Support
              Keymaster

                Hi

                You tried BitBlt procedure?

                #52679
                SzakiLaci
                Participant

                  Few things sorted out. (resize)

                  1. It is NOT recommended to use TsImage.Loadfromfile … (it can not load BMP files ! and many other formats 🙁 )

                  2. So instead I'm using TSynPicture … for manipulating + converting to BMP >> and Assign the final (resized) picture to a TsImage later.

                  3. But I still 2 big problems:

                  3.1 Somehow I loose alpha channel, when I load 32bit PNG and than convert to BMP and stretch it.

                  – if loaded directly >> no alpha shown

                  – if loaded with tSynPicture > and Assigned() >> still no sign of transparency

                  (tried both Transparency property set to True or False)

                  … I guess because it is still using the inherited methods of a normal TImage.

                  3.2 I'm using now your AC stretching code:

                  sGraphUtils.Stretch(cutOutBmp, TempBmp, sw, sh, ftMitchell, 2);

                  But it becomes FUZZY ! (looks more ugly than a simple Canvas.StretchDraw() )

                  (See attached 2th picture from close… )

                  WHY?

                  [attachment=6939:original.jpg]

                  [attachment=6940:stretched.png]

                  #52697
                  Support
                  Keymaster

                    Hello

                    What purpose of this component in your application?

                    You uses it for converting of images?

                    #52711
                    SzakiLaci
                    Participant

                      Still no success 🙁

                      Tried to install Graphics32 component pack to do the RESIZE part. It Destroyed my whole program by deleting ALL pictures saved in TImages from the *.dfm files 😡

                      It would be a really really big help, if YOU could write 1 line how to resize a picture nicely using your component ? :wub:

                      (Theoretically it SHOULD work, because your component shows pictures on top of components very beautifully … so why isn't this working direktly? :

                      Code:
                      sGraphUtils.Stretch(cutOutBmp, TempBmp, sw, sh, ftMitchell, 2);
                      #52712
                      SzakiLaci
                      Participant
                        'Support' wrote:

                        Hello

                        What purpose of this component in your application?

                        You uses it for converting of images?

                        I don't really understand, how is it relevant, but …

                        This form will be a multi-purpose module:

                        – picture selector / by keyword-search, etc…

                        – picture-database uploader = DB, downloader = HTTP, syncronizer = HTTP + DB-DB + filesys …!

                        – editor (before uploading different size/purpose/type files > needs to be “standardized” / categorized)

                        – should adapt for different size & different resolution. (from 800×480 – to – FULLHD+ )

                        … attaching some pictures.

                        #52714
                        Support
                        Keymaster

                          Hi!

                          You can try not only ftMitchell, but other modes also in the Stretch procedure.

                          You tried other options?

                          #52720
                          SzakiLaci
                          Participant
                            'Support' wrote:

                            Hi!

                            You can try not only ftMitchell, but other modes also in the Stretch procedure.

                            You tried other options?

                            No, I did not try yet, because wanted to use the BEST quality method. Will try it today and report back.

                            #52722
                            Support
                            Keymaster

                              This option can change an algorithm of resizing and quality is different for different algorithmes.

                              #52734
                              SzakiLaci
                              Participant
                                'Support' wrote:

                                This option can change an algorithm of resizing and quality is different for different algorithms.

                                Sorry for the late response. Tried Lanczos3 too. Same ( fuzzy ) results.

                                Had an interesting phone call today. An other (of your costumer) AC user reported me too:

                                – had tried to install Graphics32 component pack, and deleted all pictures stored in TImage components for him too.

                                Can you please try to install Graphics32 too? Put a simple bmp into a simple TImage (NOT TsImage), and see if it's beeing deleted after that.

                                SAVE your work in a different (ZIPed) location. I usually save the whole borland directory…

                                #52750
                                Support
                                Keymaster

                                  Maybe you can give me an example which I can try?

                                  I'll check Graphics32 soon.

                                  #52801
                                  SzakiLaci
                                  Participant
                                    'Support' wrote:

                                    Maybe you can give me an example which I can try?

                                    I'll check Graphics32 soon.

                                    Graphics32 is COOL ! 🙂

                                    Yesterday night I've successfully did what I wanted to with it. (Resize nicely)

                                    Solution was here:

                                    http://stackoverflow.com/questions/1976116/scale-an-image-nicely-in-delphi

                                    #52810
                                    SzakiLaci
                                    Participant

                                      I was happy too soon when I thought I finished 🙁

                                      TsImage is showing NO 32 bit BMP pictures under win7 64 bit, if loaded directly into it. (Under XP everything seems to be fine.)

                                      Have to test more … Agggghhhh 🙁 Hate to through away 3 month of work and start from the beginning because a component isn't working as it should 🙁 🙁 🙁

                                      (Compiled with Delphi7)

                                      #52812
                                      Support
                                      Keymaster

                                        Hi!

                                        Maybe you can show a demo with the problem?

                                        I can help better in this case…

                                        #52825
                                        SzakiLaci
                                        Participant
                                          'Support' wrote:

                                          Hi!

                                          Maybe you can show a demo with the problem?

                                          I can help better in this case…

                                          Sadly can not “cut out” part of the source code from the whole program and make a working Demo from it. It would take as much time as rewriting the whole module to an other component. (GR32 TImage32 )

                                          Sending just a screenshoot won't help you to find the bug at the component.

                                          Thanks for trying to help… :wub:

                                          #52830
                                          SzakiLaci
                                          Participant

                                            [SOLVED ! :D]

                                            Solution:

                                            1. Unistall every AlphaControls packages

                                            2. Install Graphics32 “first”

                                            3. Install AC back !

                                            (always BUILD! every package, not just Compile)

                                            Tried everything under VirtualBox > so I was able to “play” with everything without making any harm.

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