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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    BaseBitmap.ScaleIt() IS NOT WORKING

    Cinema 4D SDK
    r21 python
    2
    3
    347
    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.
    • gheyretG
      gheyret
      last edited by gheyret

      Hello! plugincafe!
      I want to save all material's preview image.
      And i try to use BaseBitmap.ScaleIt() , but it's not working.
      All images remain the before ScaleIt() size,I'm not sure what went wrong.
      there are my code:

      import c4d
      
      
      def SetBmpSize(mats,size):
          bmps = []
          for m in mats:
              image = m.GetPreview(0)
      
              dst_bmp = c4d.bitmaps.BaseBitmap()
              dst_bmp.Init(size, size)
              
              image.ScaleIt(dst_bmp, 256, True, True)
      
              bmps.append(image)
          return bmps
      
      def main():
          path = "D:\\Program Files\\my folder"
          
          mats = doc.GetMaterials()
          
          bmps = SetBmpSize(mats,32)
          for index,bmp in enumerate(bmps):
              c4d.bitmaps.ShowBitmap(bmp)
              #name = path + "\\" + str(index) + "material preview.tif"
              #bmp.Save(name, c4d.FILTER_TIF, data=None, savebits=c4d.SAVEBIT_0)
          
      
      if __name__=='__main__':
          main()
      

      this is the show in picture viewer after ScaleIt() Image:
      Snipaste_2020-02-17_04-07-47.png

      www.boghma.com

      1 Reply Last reply Reply Quote 0
      • C4DSC
        C4DS
        last edited by

        @gheyret said in BaseBitmap.ScaleIt() IS NOT WORKING:

        bmps.append(image)

        This does append the original image to your array of bmps being returned, not the scaled up one.
        you should do:

        bmps.append(dst.bmp)
        
        gheyretG 1 Reply Last reply Reply Quote 0
        • gheyretG
          gheyret @C4DS
          last edited by

          @C4DS
          Thank you for your help! It works!
          Cheers~

          www.boghma.com

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