8 Replies Latest reply on Jun 29, 2007 6:45 AM by Chunick

    Image from a string

    extol Level 1
      Is it possible to assign bitmap data to an imageObject for use with copypixels. For example:

      initialData = netTextResult(theNetID)
      myData = decompress(initialData)
      img = image(200, 200, 32)
      img = String(myData)
      img.copyPixels(movie.stage.image, rect(0, 0, 200, 200), rect(0, 0, 200, 200))
        • 1. Re: Image with getNetText
          Level 7
          Not with getNetText(), but with preloadNetThing()
          nID = preloadNetThing("URL")
          -- ... wait for netDone() to return TRUE
          tMember = _movie.newMember(#bitmap)
          tMember.filename = "URL" -- see above
          -- check filename assignment
          if tMember.type <> #bitmap then exit
          tImage = tMember.image.duplicate()
          -- optionally delete member:
          -- continue with image manipulation ...
          • 2. Re: Image with getNetText
            extol Level 1
            Thanks for the reply, Sean! I should have been more specific. The data I am loading is not an image file. It is a string. I am loading a file with 3 images compressed together. Then decompressing it using lingo into a string. Then I want to use that string to draw my bitmap using copypixels. I can do it buy going through and using setpixel to draw each pixel. But that's too slow. I want to use copypixels.
            • 3. Re: Image from a string
              johnAq Level 1
              Can you give more information - how is the file compressed/created? You may need to write it to a temp file and decompress that to temp as well, then load the images in as images & delete the temps


              • 4. Image from a string
                Chunick Level 3
                the major problem is that copyPixels works with image objects... you need to have two image objects in Director.... there's no problem with this part of your pseudocode:
                img = image(200, 200, 32)

                but there's a bunch of steps not showing here:
                img = String(myData)

                and, in fact, that line simply shows the data being converted to a string. It has to get into an image object before copyPixels can be used, ie. if you import an image into a cast member by using importFileInto() or the .fileName parameter of a member then you will have your image object in Director ready to manipulate with copyPixels.
                • 5. Re: Image from a string
                  extol Level 1
                  Hey, Chunick. Thanks for your reply and for the link. You have a lot of awesome examples and I bookmarked that page. What you suggested totally makes sense. But I'm afraid that I was unclear about what I am trying to do. What I would like to do is this:

                  Have information sent over the server (such as Flash Media Server). Decompress that information using an algorythm such as GZip. Make it into 3 separate images. Copy those images onto the screen.

                  Since I may not even be dealing with a file, I can't just use the .fileName property. Also, I need to parse the data before it's usable as image data.

                  Why do I want to do this??? Well, what I am trying to do is make a 4-way scroller using a tilemap. Each tile needs to load: an 8-bit alpha channel, an 1-bit bitmask, a 24-bit image. Then they are used to create the tile, using the alpha channel for the shape, the image for the colors, and the bitmask for walkability. I need those items to load IN THAT ORDER so that I can at least draw the shape and get the walkability even if the tile hasn't compeletly loaded yet. I wanted to compress them all together to make things smaller.

                  Maybe I am just asking too much lol! Isn't there a way to just convert a string of data into an imageobject? Thanks for any help.
                  • 6. Re: Image from a string
                    McFazstp Level 1
                    What if you saved the images in a castLib and published it as a shockwave cct. The file size would be small and you could download a single file and link to it to pull the images.
                    • 7. Re: Image from a string
                      extol Level 1
                      Thanks, McFazstp. I am trying that and it seems to work pretty good. It compresses everything to be small and loads how I want. Thanks!!!
                      • 8. Re: Image from a string
                        Chunick Level 3
                        glad to see McFazstp's excellent suggestion is working for you. Good luck on the project.