3 Replies Latest reply on Aug 15, 2007 5:09 AM by James Newton, ACP

    Extracting pixel data from rotated bitmap

    Jan_Carlo Level 1
      Hello to you

      I am trying to extract pixel information from a BMP image under various rotations.

      To extract pixel information from the image the string: member().image.getPixel(), is used.

      To rotate the image the string:
      sprite(1).rotation = value, is used.

      The problem is that the image this way only seem to rotate in the stage, not the image it self. I get the same (0 rotation) output no matter what rotation the image seems to have on the stage.

      I have attached a piece of the code below and would be thankful for any suggestions on how to solve the problemJ

      Have a glittering day :)
        • 1. Re: Extracting pixel data from rotated bitmap
          johnAq Level 1
          The sprite rotation does not change the underlying member data, in the same way that changing the size of position doesn't. To perform the same operation with script you need to use Imaging Lingo - specifically using copyPixels.

          With copyPixels, you can set a destination quad (four non-rectangular points) to copy image data from one image to another. Your code would look something like

          srcImage = member(AnalysedImage).image

          destimage = image(new width, newHeight, 32) -- a new image for the rotation, you'll need to calculate a new height & width based on your rotation.

          destQuad = calculatedQuad --the rotated corner points for your image -once again, some kind of mathematical rotation that I don't know OTTOMH

          destimage.copyPixels(srcImage, destinationQuad, srcImage.rect)

          hth as a start

          • 2. Re: Extracting pixel data from rotated bitmap
            Jan_Carlo Level 1
            Thank you it put me in the right direction:)
            • 3. Re: Extracting pixel data from rotated bitmap
              James Newton, ACP Level 3
              See code below for rotating an image. The resulting image will not have the same precision as the original.
              Alternatively, you could simply rotate the sprite (as you are currently doing) then use...

              vMemberLoc = sprite(x).mapStageToMember(the mouseLoc)

              ... to determine which point of the unrotated member appears under the mouse in the rotated sprite.