12 Replies Latest reply on Aug 25, 2006 4:03 AM by chrisosh

    ActiveX image data wrong (perhaps binary)

    chrisosh

      I am using an ActiveX control that returns an image to me. The event works, the image size & dpi is returned but the image object is returned as a string of about 600 question marks, i.e. "????????????????????"

      Ive been told it could be binary data, (byte array?).

      Any idea how to get this into an image in Director?

      Thanks very much.
        • 1. Re: ActiveX image data wrong (perhaps binary)
          the real POTMO Level 1
          I think i can put my socks on that its binary data.

          >Any idea how to get this into an image in Director?

          that depends on what format the image is in.
          If its i.e. jpeg then youll have to decode it and setpixels() on an image object.
          If its raw it might be easier. but it will never be easy.
          Try opening it in a hexeditor and try to find out what kind of data it is.
          Seach the web for decoding algorithms if its encoded binary data.
          • 2. Re: ActiveX image data wrong (perhaps binary)
            chrisosh Level 1
            Its not JPEG.
            Apparently its raw data, an 8bit greyscale image.

            I found this in the help file:
            "is an array of width * height unsigned bytes. Each byte represents a single pixel of the image. The array is arranged in left to right, top to bottom order. There's no padding, each line immediately follows the previous one. Each pixel has a grayscale value ranging from 0 (pure black) to 255 (pure white)."

            It doesnt return a list of numbers though, just a string full of lots of ? question marks.

            Thanks
            • 3. Re: ActiveX image data wrong (perhaps binary)
              Level 7
              chrisosh wrote:
              > Its not JPEG.
              > Apparently its raw data, an 8bit greyscale image.
              >
              > I found this in the help file:
              > "is an array of width * height unsigned bytes. Each byte represents a
              > single pixel of the image. The array is arranged in left to right,
              > top to bottom order. There's no padding, each line immediately
              > follows the previous one. Each pixel has a grayscale value ranging
              > from 0 (pure black) to 255 (pure white)."
              >
              > It doesnt return a list of numbers though, just a string full of lots
              > of ? question marks.

              A string is just a load of numbers representing characters. The ?s mean the
              numbers map to ? characters.

              Simply use charToNum() on each char of the "string" to get the actual
              values.

              Andrew


              • 4. ActiveX image data wrong (perhaps binary)
                chrisosh Level 1
                Just some extra information that might help. The ActiveX returns an width property of 355, a height of 390 and a dpi of 500. The image property is a string "????????" of 69225 question marks.

                quote:

                A string is just a load of numbers representing characters. The ?s mean the
                numbers map to ? characters.

                Simply use charToNum() on each char of the "string" to get the actual
                values.


                Thanks for the reply Andrew

                I tried to use charToNum on each char in the string, but it simply returns integer 63. The string does really seems to contain lots of question marks.

                -- e.g
                put "?".charToNum
                -- 63

                This is doing my head in.
                • 5. Re: ActiveX image data wrong (perhaps binary)
                  Level 7
                  On Tue, 22 Aug 2006 19:08:51 GMT, chrisosh posted in
                  macromedia.director.lingo:

                  > Just some extra information that might help. The ActiveX returns an
                  > width property of 355, a height of 390 and a dpi of 500. The image
                  > property is a string "????????" of 69225 question marks.

                  Those are likely unprintable characters that Director represents as question
                  marks.

                  Rather than getting the charToNum of a question mark, try getting it for each
                  character of the data string returned by the ActiveX, as Andrew suggested.

                  put charToNum(imageStringFromYourActiveX[1])


                  --
                  Mark A. Boyd
                  Keep-On-Learnin' :)
                  • 6. Re: ActiveX image data wrong (perhaps binary)
                    chrisosh Level 1
                    quote:

                    Rather than getting the charToNum of a question mark, try getting it for each
                    character of the data string returned by the ActiveX, as Andrew suggested.
                    put charToNum(imageStringFromYourActiveX[1])


                    Sorry I should have said, this is what I did do. I only did the put "?".charToNum to make sure it was 63 for question marks.

                    My code looks like this:

                    on gotImage(me, tsensor, twidth, theight, timage, tdpi)
                    put tsensor, twidth, theight, tdpi
                    put timage.length
                    repeat with i = 1 to timage.length
                    temp = timage.char[1..1]
                    put temp.charToNum
                    end repeat
                    end

                    gotImage is an event that is called when an image is made, with timage being the rawImage data.

                    This outputs 63 into the message window 69225 times.
                    timage is a long string, not an array of data.

                    Thanks


                    • 7. Re: ActiveX image data wrong (perhaps binary)
                      Level 7
                      On Tue, 22 Aug 2006 23:21:05 GMT, chrisosh posted in
                      macromedia.director.lingo:

                      > My code looks like this:
                      >
                      > on gotImage(me, tsensor, twidth, theight, timage, tdpi)
                      > put tsensor, twidth, theight, tdpi
                      > put timage.length
                      > repeat with i = 1 to timage.length
                      > temp = timage.char[1..1]
                      > put temp.charToNum
                      > end repeat
                      > end
                      >
                      > gotImage is an event that is called when an image is made, with timage
                      > being the rawImage data.
                      >
                      > This outputs 63 into the message window 69225 times.
                      > timage is a long string, not an array of data.

                      There's a possibility that the first char actually is 63. Your code is
                      outputting only the first char 69225 times.

                      Try changing this line:

                      temp = timage.char[1..1]

                      to this:

                      temp = timage.char

                      (or, in case the Web forum still sees bracket i bracket as an italics tag):

                      temp = timage.char[ i ]

                      Also, just to eliminate another possibility, does this ActiveX work as
                      expected outside of Director?


                      --
                      Mark A. Boyd
                      Keep-On-Learnin' :)
                      • 8. Re: ActiveX image data wrong (perhaps binary)
                        chrisosh Level 1
                        Sorry my bad, actually my code reads
                        timage.char[i..i]
                        I changed it to test and forgot to put back in before posting.

                        the above, and timage.char[ i ] output just 63 each time.

                        How can I test image formats outside Director? I'm not a C++ coder or Java developer unfortunately.

                        • 9. Re: ActiveX image data wrong (perhaps binary)
                          Level 7
                          I was going to ask the same thing. Can you get the ActiveX to work
                          elsewhere, like in VB?

                          You might have to write your own VB wrapper ActiveX for that ActiveX, that
                          sets up the bytes of data you need and returns it in a format Director
                          likes. Actually I see earlier in the thread it returns unsigned bytes.

                          63 is actually the 64th item or 111111 binary so it's only returning 6 bits
                          of the byte. FWIW
                          Also, 350 x 390 / 2 = 69225, but it seems like you should be getting 138,450
                          separate bytes, so when Director is getting the data, it's making pairs of
                          the bytes or something.

                          In Director, if you double click the activeX so it pops up the list of
                          Methods, and you click on the one that returns the data you need, it should
                          say the type of variable. Such as "returns a string". Does it say byte, byte
                          array or anything besides string?

                          TR

                          "Mark A. Boyd" <mblist@sanDotrr.com.invalid> wrote in message
                          news:Xns98285DE54870mblistssanDotrrcom@216.104.212.96...
                          > On Tue, 22 Aug 2006 23:21:05 GMT, chrisosh posted in
                          > macromedia.director.lingo:
                          >
                          >> My code looks like this:
                          >>
                          >> on gotImage(me, tsensor, twidth, theight, timage, tdpi)
                          >> put tsensor, twidth, theight, tdpi
                          >> put timage.length
                          >> repeat with i = 1 to timage.length
                          >> temp = timage.char[1..1]
                          >> put temp.charToNum
                          >> end repeat
                          >> end
                          >>
                          >> gotImage is an event that is called when an image is made, with timage
                          >> being the rawImage data.
                          >>
                          >> This outputs 63 into the message window 69225 times.
                          >> timage is a long string, not an array of data.
                          >
                          > There's a possibility that the first char actually is 63. Your code is
                          > outputting only the first char 69225 times.
                          >
                          > Try changing this line:
                          >
                          > temp = timage.char[1..1]
                          >
                          > to this:
                          >
                          > temp = timage.char
                          >
                          > (or, in case the Web forum still sees bracket i bracket as an italics
                          > tag):
                          >
                          > temp = timage.char[ i ]
                          >
                          > Also, just to eliminate another possibility, does this ActiveX work as
                          > expected outside of Director?
                          >
                          >
                          > --
                          > Mark A. Boyd
                          > Keep-On-Learnin' :)


                          • 10. Re: ActiveX image data wrong (perhaps binary)
                            Level 7
                            On Wed, 23 Aug 2006 17:18:03 GMT, chrisosh posted in
                            macromedia.director.lingo:

                            > How can I test image formats outside Director? I'm not a C++ coder or
                            > Java developer unfortunately.

                            I don't use ActiveX myself. See if tr's message helps in this regard -
                            assuming you're asking about testing the ActiveX outside of Director.

                            Which ActiveX control are you using? Is it freely or commercially available
                            to the public?


                            --
                            Mark A. Boyd
                            Keep-On-Learnin' :)
                            • 11. Re: ActiveX image data wrong (perhaps binary)
                              chrisosh Level 1
                              Thanks again for your replies.

                              TR, sounds like you know what you are talking about :)

                              I have opened activex, it is an event not a method, but it says:
                              ImageAcquired returns an integer
                              Parameter 1: idSensor is a string
                              Parameter 2: width is an integer
                              Parameter 3: height is an integer
                              Parameter 4: rawImage is a string
                              Parameter 5: res is an integer

                              Unfortunately I don't know VB.

                              Mark, the ActiveX control is this:
                              http://www.griaule.com/page/en-us/grfinger_sdk

                              Its a free trial download, but you have to buy it once the trial runs out.

                              Many thanks again, really appreciate it
                              • 12. Re: ActiveX image data wrong (perhaps binary)
                                chrisosh Level 1
                                Hmm, I'm still not getting any further than this, and the people who made the ActiveX said they won't support it out side software environments like c++, java and vb.

                                Any thoughts on previous post?