Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    getting resolution of bitmap

    Scheduled Pinned Locked Moved PYTHON Development
    7 Posts 0 Posters 553 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.
    • H Offline
      Helper
      last edited by

      On 20/11/2013 at 06:35, xxxxxxxx wrote:

      I'm creating a new material and importing an external .png file into it.  I have all of that working well but I would like to get the DPI of the image that was imported.  I don't see anything for c4d.BaseBitmap that allows me to get that info.  I see that MultipassBitmap allows you to get the DPI but I'm having trouble getting that to work.  Any help or direction is appreciated.

      I pulled these lines out of the script that deal with this part.

      bmp = c4d.bitmaps.BaseBitmap()
      if bmp.InitWith(pathToPNGfile)[0] != c4d.IMAGERESULT_OK:
              gui.MessageDialog("Please choose a valid image format.")
              return

      width, height = bmp.GetSize() #this gives me the dimensions of my .png file but I need to know DPI as well

      mbp = c4d.bitmaps.MultipassBitmap.AllocWrapper(bmp)
          
      print mbp.GetParameter(8)  #I thought this would return the DPI but instead it prints 'None'

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 20/11/2013 at 07:00, xxxxxxxx wrote:

        Hi .del,

        how do you come to the conclusion that mbp.GetParameter(8) returns the DPI? The documentation
        states that c4d.MPBTYPE_DPI is the parameter ID associated with the DPI.

        import c4d
        from c4d import gui
          
        def main() :
            path = c4d.storage.LoadDialog()
            if not path: return
            bmp = c4d.bitmaps.BaseBitmap()
            if bmp.InitWith(path)[0] != c4d.IMAGERESULT_OK:
                    gui.MessageDialog("Please choose a valid image format.")
                    return
          
            mbp = c4d.bitmaps.MultipassBitmap.AllocWrapper(bmp)
            print mbp.GetParameter( **c4d.MPBTYPE_DPI** ) 
          
        main()
        

        PS: Please use the BB code tags for posting your code or give it a monospaced font. It will also
        make it easier for others if you including a full example script, if possible. (including imports etc.
        as I did).

        Best,
        -Niklas

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 20/11/2013 at 07:28, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          Hi .del,

          how do you come to the conclusion that mbp.GetParameter(8) returns the DPI? The documentation
          states that c4d.MPBTYPE_DPI is the parameter ID associated with the DPI.

          AAARRGGGGHHHH!!  I had tried MPBTYPE_DPI but it didn't work.  I blew putting the c4d. in front of it. The documentation said the Parameter is an int  so when my first attempt didn't work I counted down the list and came up with 8.  What can I say, I'm totally new at this and giving it a shot before coming on here.

          I appreciate the clarification and the tip on using the code tag.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 21/11/2013 at 06:03, xxxxxxxx wrote:

            The script is working but it always returns 72 regardless of the files actual dpi.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 26/11/2013 at 06:22, xxxxxxxx wrote:

              I can confirm. I'll find out how to read the DPI.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 05/12/2013 at 08:16, xxxxxxxx wrote:

                Reading the DPI when loading an image is not supported with the current state of the API.

                Best,
                -Niklas

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 06/12/2013 at 09:33, xxxxxxxx wrote:

                  Does the state of the API ever change?

                  Is this an option in another language?  I'm starting to feel like Python in C4D on a Mac isn't quite there yet.  I'm working on a relatively short script have already come across two functions in the sdk that don't work.  Should I be looking at coffee instead or make the move to C++?

                  Thanks for your help.

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