8 Replies Latest reply on Jun 26, 2006 7:13 PM by Newsgroup_User

    Bluring images in Projector

    Level 7
      Is there a way to blur an image in a projector? While it is running?


        • 1. Re: Bluring images in Projector
          Level 7
          If you are using Director MX2004 with the newest update so you can use
          the new Flash filters, you can use this movie script to blur any bitmap
          image on the fly:

          You need to feed it at the least a #image, so for instance, if you have
          a sprite on the stage (let's say sprite(1)), and you want it to be a
          blurred image of member("somethingToBlur"), then you would use this code:

          sprite(1).member.image=blur(member("somethingToBlur"))

          You can add more options by passing a second parameter in the form of a
          list (see the examples in the header of the script). Bear in mind that
          when you make your projector, you will need to make sure to include the
          Flash Asset Xtra in order for this lingo to work (and it needs to be the
          latest version- 10.1.1 r16).

          --

          --#movie script
          --Watch for line wrapping problems...
          on blur vImage, vOptions

          -----------------------------------------------------------------------------------------
          -- USAGE:
          ----------This takes an #image object as its input and returns a
          filtered image
          --
          -- INPUTS:
          ----------vImage -Image - the original #image that
          will get the filter applied
          --
          ----------vOptions[#blur] - Integer - (0-255) - should be a
          power of 2 for best results
          ----------vOptions[#quality] - Integer - (0-15) - the number of
          times to perform the blur
          -- 1 = softly unfocused
          -- 3 = gaussian blur
          --
          -- OPTIONAL:
          ----------vOptions[#blurX] is optional and will override #blur on the
          X axis if it exists
          ----------vOptions[#blurY] is optional and will override #blur on the
          Y axis if it exists
          --
          -- RETURNS:
          -----------Returns a filtered #image object
          --
          -- EXAMPLES:
          -----------someImage=sprite(1).blur
          -----------someImage=blur (sprite(1).member.image, [#blur:10,#quality:3])
          -----------someImage=blur (sprite(1).member,[#blur:10,#quality:3])
          -----------someImage=blur (sprite(1),[#blur:10,#quality:3])
          --
          --HISTORY:
          -- --May 2006 - Written by Mike Blaustein, MediaMacros, inc,

          -----------------------------------------------------------------------------------------

          --defaults

          case vImage.ilk of
          #image:
          vImage=vImage
          #member:
          vImage=member(vImage).image
          #sprite:
          vImage=sprite(vImage).member.image
          end case

          if vOptions.ilk<>#propList then
          vOptions=[#blur:4,#quality:1]
          end if

          if voidP(vOptions[#blur]) then vOptions[#blur]=4
          if voidP(vOptions[#quality]) then vOptions[#quality]=1
          --defaults

          gBlurFilter = newObject("flash.filters.BlurFilter")

          if voidP(vOptions[#blurX]) then
          gBlurFilter.blurX=vOptions[#blur]
          else
          gBlurFilter.blurX=vOptions[#blurX]
          end if

          if voidP(vOptions[#blurY]) then
          gBlurFilter.blurY=vOptions[#blur]
          else
          gBlurFilter.blurY=vOptions[#blurY]
          end if

          gBlurFilter.quality = vOptions[#quality]

          bm=convert(#bitmapdata,vImage)
          pt = newObject("flash.geom.point", 0, 0)
          r = bm.rectangle

          --convert the Flash #bitmapData object back into a Director #image
          -- returns 0 if it worked, negative errors if not
          errorCode= bm.applyFilter(bm, r,pt,gBlurFilter)
          -- put errorCode
          newImage=convert(#image,bm)

          --release the memory
          bm.dispose()
          gBlurFilter=void

          return newImage
          end
          • 2. Re: Bluring images in Projector
            Level 7
            Alas, I'm on 8.5

            Is there another way?


            • 3. Re: Bluring images in Projector
              a¿ex
              the directimage xtra can do that, but if you do not want to shelf the upgrade price for director 10, which I would recommend in this case, you probably won't buy an xtra, too...

              here's a lingo solution which works in 8.5, however be aware, that it is dog slow and very limited:
              < http://www.farbflash.de/cgi-bin/blosxom.cgi/Dokumente/Director/Snippets/gaussian.html>
              • 5. Re: Bluring images in Projector
                Level 7
                Here's a simple method:

                on doBlur(theImage, theBlur)
                p = image(theImage.width / theBlur, theImage.height / theBlur, 24)
                q = image(theImage.width, theImage.height, 24)
                p.copyPixels(theImage, p.rect, theImage.rect)
                q.copyPixels(p, q.rect, p.rect)
                return q
                end


                It simply creates a new image smaller than the original by dividing the
                width and height of the original by the blur factor. Then it copy pixels the
                original into the smaller and then into another image the same size as the
                original, which it returns. Might work for you...



                --
                Dave -
                Adobe Community Expert
                www.blurredistinction.com
                http://www.adobe.com/communities/experts/


                • 6. Bluring images in Projector
                  Chunick Level 3
                  quote:

                  Originally posted by: Newsgroup User
                  Here's a simple method:

                  on doBlur(theImage, theBlur)
                  p = image(theImage.width / theBlur, theImage.height / theBlur, 24)
                  q = image(theImage.width, theImage.height, 24)
                  p.copyPixels(theImage, p.rect, theImage.rect)
                  q.copyPixels(p, q.rect, p.rect)
                  return q
                  end


                  It simply creates a new image smaller than the original by dividing the
                  width and height of the original by the blur factor. Then it copy pixels the
                  original into the smaller and then into another image the same size as the
                  original, which it returns. Might work for you...



                  --
                  Dave -
                  Adobe Community Expert
                  www.blurredistinction.com
                  http://www.adobe.com/communities/experts/


                  Dave, that's a horrible algorithm for blurring... although, it would be great for a pixelation effect. ;-)
                  the reason it pixelates is because the algorithm used by copypixels for resizing is equivalent to nearest neighbor. No sub-pixel sampling is done, whatsoever.
                  • 7. Re: Bluring images in Projector
                    Level 7
                    >> Dave, that's a horrible algorithm for blurring... although, it would be
                    >> great
                    for a pixelation effect. ;-)


                    <G> Yeah, it really would depend on what he's after, for sure. But you're
                    right it's definitely better for pixelizing than blurring... just thought
                    I'd throw it out there.

                    --
                    Dave -
                    Adobe Community Expert
                    www.blurredistinction.com
                    http://www.adobe.com/communities/experts/


                    • 8. Re: Bluring images in Projector
                      Level 7
                      This works good enought for my purposes. THX


                      "Chunick" <webforumsuser@macromedia.com> wrote in message
                      news:e7k1r2$6t1$1@forums.macromedia.com...
                      > fast image blur (lingo):
                      > http://www.mediamacros.com/item/item-1006687608/