HISE Logo Forum
    • Categories
    • Register
    • Login

    Get the size of an image loaded into a panel

    Scheduled Pinned Locked Moved General Questions
    4 Posts 2 Posters 133 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ustkU
      ustk
      last edited by ustk

      I'd like to draw an image centred in a panel, but without being able to calculate the ratio, I can only center it either vertically or horizontally.

      I can do g.drawImage([this.getWidth()/4, this.getHeight()/4, this.getWidth()/2, this.getHeight()/2], 0, 0)

      But when the ratio of the image is not the same than the one of the panel, the larger dimension wins the race.

      So is there a way to get the width and height of a loaded image?

      Can't help pressing F5 in the forum...

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @ustk
        last edited by d.healey

        @ustk Yes, you added it to HISE, then I also added it, and Christoph hasn't merged either, maybe he doesn't want to pick a favourite :)

        https://github.com/christophhart/HISE/pull/289
        https://github.com/christophhart/HISE/pull/403

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        ustkU 2 Replies Last reply Reply Quote 1
        • ustkU
          ustk @d.healey
          last edited by

          @d-healey
          2.5 years that I added it
          lol-1bytr09oaz8qsffm.gif

          Can't help pressing F5 in the forum...

          1 Reply Last reply Reply Quote 0
          • ustkU
            ustk @d.healey
            last edited by

            @d-healey Actually a mix of the two might be a better candidate, keeping the w/h separated, and removing the for loop for a more direct getLoadedImage(imageName)
            @Christoph-Hart ?

            Can't help pressing F5 in the forum...

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            19

            Online

            1.7k

            Users

            11.9k

            Topics

            103.7k

            Posts