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

    Writing 32 color information to ByteSeq

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 219 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 17/06/2013 at 03:08, xxxxxxxx wrote:

      I'm trying to partly copy 32 bit images.
      Copying a part of an image to another images is working.
      However, when I tried to set my own 32 bit pixel color information it goes wrong.

      I do not know how to initialize the byteseq with 32 bit color information.
      I tried this, but it comes out all black. No color information.

      What I do:
      - create a byteseq for 1 pixel. 32 bits x 3 colors = 96 bits = 12 bytes
      - fill the byteseq with R=0xFFFFFFFF, G=0, B=0xFF
      - write the pixel to the image, but no colors. Everything is black

          b12 = storage.ByteSeq(None, 12)                     	# size = 12 bytes = 1 pixel
          b12[0:4]  = chr(255)*4                              		# 0xFFFFFFFF
          b12[4:8]  = chr(0)*4                                		# 0x00000000
          b12[8:12] = chr(0) + chr(0) + chr(0) + chr(255)     # 0x000000FF
        
          #copy to image 
          for row in range(100,400) :
              for x in range (200,800) :
                  #offset = b12.GetOffset(0)                  #offset in byteseq
                  pixels2copy = 1
                  copy.SetPixelCnt(x, row, pixels2copy, b12, inc, c4d.COLORMODE_RGBf, c4d.PIXELCNT_0) # Set pixels in bitmap copy
          
        
          bitmaps.ShowBitmap(copy) # Show copied image
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 17/06/2013 at 07:20, xxxxxxxx wrote:

        This seems to work.
        One thing that puzzles me, is the format of the value I can give.
        0xffffffff, 0.9999, 1.0, it is all ok.

            b12 = storage.ByteSeq(None, 12)
            b12[0:4]  = struct.pack("f", 0xffffffff)            # R
            b12[4:8]  = struct.pack("f", 0.9999)                # G
            b12[8:12] = struct.pack("f", 1.0)                   # B
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post