archive-com.com » COM » C » CRAFTYMIND.COM

Total: 161

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Sean Christmann | Craftymind | Page 5
    view first The reason the magnifier view is teh same size as the original view is because we are rendering the full context of the original view into our new context before grabbing a bitmap of it If the magnifying view were smaller the rendered bitmap would also be smaller We want to cache the final bitmap so we re not redrawing the original view every time the user moves their finger around the view We ll destroy that cached view and the magnifying glass when the user lets up off the screen void drawRect CGRect rect if cachedImage nil UIGraphicsBeginImageContext self bounds size self viewref layer renderInContext UIGraphicsGetCurrentContext cachedImage UIGraphicsGetImageFromCurrentImageContext retain UIGraphicsEndImageContext Following that we need to generate a masked view for the magnified view to sit in since the loop is a circle we have to mask out the corners and antialias the outer perimeter This is accomplished using 2 images the magnifying glass itself and a mask image with appropriate grayscale levels for masking CGImageRef imageRef cachedImage CGImage CGImageRef maskRef UIImage imageNamed loopmask png CGImage CGImageRef overlay UIImage imageNamed loop png CGImage CGImageRef mask CGImageMaskCreate CGImageGetWidth maskRef CGImageGetHeight maskRef CGImageGetBitsPerComponent maskRef CGImageGetBitsPerPixel maskRef CGImageGetBytesPerRow maskRef CGImageGetDataProvider maskRef NULL true Create Mask CGImageRef subImage CGImageCreateWithImageInRect imageRef CGRectMake touchPoint x 18 touchPoint y 18 36 36 CGImageRef xMaskedImage CGImageCreateWithMask subImage mask Lastly we ll draw the magnifying glass and magnfied bitmap copy of our orginal view underneath the mask and we re done Since the iPhone uses a different coordinate system then other languages we have to remember to flip the view upside down before drawing it CGContextRef context UIGraphicsGetCurrentContext CGAffineTransform xform CGAffineTransformMake 1 0 0 0 0 0 1 0 0 0 0 0 CGContextConcatCTM context xform CGRect area CGRectMake touchPoint x 42 touchPoint y 85 85 CGRect area2 CGRectMake touchPoint x 40 touchPoint y 2 80 80 CGContextDrawImage context area2 xMaskedImage CGContextDrawImage context area overlay And that s it now we have a modular magnifying glass that can plug in to any UIView with minimal effort If you re looking for a way to add interactivity underneath the magnifying glass like moving the cursor within a textfield that s gonna require a bit more custom code on the control you re dealing with and this example doesn t really address that Download example XCode magnifier example for iPhone AIR Flash Flex Max 2008 session material November 20 2008 Sean Christmann 11 Comments As promised here s the pdf of my recent Max 2008 session Optimizing Adobe AIR for Code Execution Memory and Rendering There s a good amount of Flash VM tips and tricks in there for reference whether you re working in the browser or AIR Thanks to everyone who attended and gave me high marks for my session I guess I have to start thinking about what to talk about next year For anyone who didn t get to see the session live the pdf really only tells half the story so you may want

    Original URL path: http://www.craftymind.com/author/admin/page/5/ (2016-04-27)
    Open archived version from archive


  • Sean Christmann | Craftymind | Page 8
    gc and we were set to go right Well not exactly First off we learned that a call to System gc only does a mark OR a sweep on any given object but not both in the same call So in order to have the effect of releasing memory back to the OS we needed to call it twice in a row One call to mark any dereferenced objects and sweep away old marks and the second to now sweep away marks from the first call flash system System gc flash system System gc Now this seemed to be releasing memory back with pretty basic test cases but it wasn t working under production scenarios and we had to turn to Adobe engineers to help with the problem What we learned was that you have to contend with 2 different kinds of pointers when working in AS3 pointers that exist in bytecode and pointers that may exist in the Flash player itself that you d never know about What I started to realize was that the Flash player was never really engineered to be aggressive about memory usage It was designed to plug memory leaks and manage memory plateaus but not designed with an assumption that users would be interested in lowering those plateaus It makes sense because most Flash content is viewed in the browser for a short amount of time before the plugin is destroyed and all memory is released when a user navigates away With AIR the rules changed since users are more conscience of discreet application memory usage and applications might not always need the same memory when launched vs after 2 hours of usage First up we found that the Flash player was always maintaining a reference to the last Sprite clicked so if you destroyed an AIR window that the users had interacted with you couldn t get garbage collection to work until interacting with another window which can become a big problem if you re running in system tray mode and there are no windows to click in Secondly we learned that you have to push any existing enterframe handler off the call stack by creating a new one Adobe took care of the first problem but to handle the second one we had to change our GC call a bit private var gcCount int private function startGCCycle void gcCount 0 addEventListener Event ENTER FRAME doGC private function doGC evt Event void flash system System gc if gcCount 1 removeEventListener Event ENTER FRAME doGC Another facet we hadn t considered was the affects of the Flex framework on garbage collection Flex kept some of the same design philosophy as the player itself mainly that end users were loading applications in the browser and then navigating away when done Garbage collection was therefore considered on a micro level involving user components but not at the framework level which could be guaranteed to exist throughout the life of the app Adobe made strides on patching the framework to work better in discreet Windows but ultimately some things couldn t be changed What we found was that CSS could not be defined in any mx Window component It had to be defined in the root mx WindowedApplication which would take care of declaring CSS globally for all windows Also we were forced to clear some global variables ourselves which caused our code to now look like this private var gcCount int private function startGCCycle void ContainerGlobals focusedContainer this gcCount 0 addEventListener Event ENTER FRAME doGC private function doGC evt Event void flash system System gc if gcCount 1 removeEventListener Event ENTER FRAME doGC Lastly not all features in AIR could be unhooked with our enterFrame trick after another couple days of testing we found components that needed to be unhooked with Timers like the HTML component One last tweak to our garbage collection cycle and we were home free private var gcCount int private function startGCCycle void gcCount 0 addEventListener Event ENTER FRAME doGC private function doGC evt Event void flash system System gc if gcCount 1 removeEventListener Event ENTER FRAME doGC setTimeout lastGC 40 private function lastGC void flash system System gc We were now able to successfully garbage collect any objects that have been dereferenced in Flash We had three things we had to look out for in the app now All display objects that added listeners on to model data had to be weakly referenced or they wouldn t be automatically dereferenced This is because our architecture kept model data alive while individual window stages were being destroyed I feel like I should point out that contrary to some beliefs it is not a good idea to apply weak references by default throughout your entire app Trust me when I say that its alot easier to debug an application with memory leaks due to strong listeners then it is to debug an app in which users report random failures because underneath the hood weakly referenced objects are getting accidentally destroyed when the GC kicks in You can never avoid bugs so you should program in a way that makes them consistent to find All asynchronous events needed to be explicitly shut down This included Timers Loaders File and DB transactions Setting these to be weakly referenced is not enough as all asyncronous objects in AS3 register themselves to the Flash player while they are running It is impossible to access objects that have been dereferenced in code but continue to be referenced by the player like a running timer No anonymous closures allowed After all this was taken care of we began to learn that garbage collecting objects in Flash didn t translate so easily to releasing memory back to the OS If you ever look at the memory graph in the Flex debugger and then open up the Task Manger or Activity Monitor to compare memory usage you ll notice a huge disparity between the two FlexBuilder reports only 15mb of AS3

    Original URL path: http://www.craftymind.com/author/admin/page/8/ (2016-04-27)
    Open archived version from archive

  • Index of /factory/FlexCustomCSS/assets
    Index of factory FlexCustomCSS assets Name Last modified Size Description Parent Directory style1 swf 30 Mar 2008 16 36 18K style2 swf 30 Mar 2008 16 36 18K

    Original URL path: http://www.craftymind.com/factory/FlexCustomCSS/assets/ (2016-04-27)
    Open archived version from archive

  • Index of /factory/checkerillusion/history
    checkerillusion history Name Last modified Size Description Parent Directory history css 23 Aug 2008 01 59 365 history js 23 Aug 2008 01 59 23K historyFrame html 23 Aug 2008

    Original URL path: http://www.craftymind.com/factory/checkerillusion/history/ (2016-04-27)
    Open archived version from archive

  • HTML - DHTML Test
    fringilla sed malesuada sed laoreet in dolor Donec ipsum enim rhoncus vel hendrerit ac fermentum non libero Etiam id turpis Quisque dignissim nunc non porta mattis nisl pede tincidunt purus sit amet rhoncus turpis felis ut nunc In velit turpis vestibulum et pulvinar in dignissim a tortor Quisque imperdiet erat id est Pellentesque sodales imperdiet leo Suspendisse placerat Nullam vel tellus Nulla blandit augue sed pretium mollis leo libero consequat libero ut euismod velit magna vel nisl Donec posuere blandit pede Nam et nibh ac eros malesuada gravida Ut eget erat non arcu viverra eleifend Morbi porta risus vel tortor Ut massa Lorem ipsum dolor sit amet consectetuer adipiscing elit Morbi justo lacus fringilla sed malesuada sed laoreet in dolor Donec ipsum enim rhoncus vel hendrerit ac fermentum non libero Etiam id turpis Quisque dignissim nunc non porta mattis nisl pede tincidunt purus sit amet rhoncus turpis felis ut nunc In velit turpis vestibulum et pulvinar in dignissim a tortor Quisque imperdiet erat id est Pellentesque sodales imperdiet leo Suspendisse placerat Nullam vel tellus Nulla blandit augue sed pretium mollis leo libero consequat libero ut euismod velit magna vel nisl Donec posuere blandit pede Nam et nibh ac eros malesuada gravida Ut eget erat non arcu viverra eleifend Morbi porta risus vel tortor Ut massa Lorem ipsum dolor sit amet consectetuer adipiscing elit Morbi justo lacus fringilla sed malesuada sed laoreet in dolor Donec ipsum enim rhoncus vel hendrerit ac fermentum non libero Etiam id turpis Quisque dignissim nunc non porta mattis nisl pede tincidunt purus sit amet rhoncus turpis felis ut nunc In velit turpis vestibulum et pulvinar in dignissim a tortor Quisque imperdiet erat id est Pellentesque sodales imperdiet leo Suspendisse placerat Nullam vel tellus Nulla blandit augue sed pretium mollis leo libero consequat libero ut euismod velit magna vel nisl Donec posuere blandit pede Nam et nibh ac eros malesuada gravida Ut eget erat non arcu viverra eleifend Morbi porta risus vel tortor Ut massa Lorem ipsum dolor sit amet consectetuer adipiscing elit Lorem ipsum dolor sit amet consectetuer adipiscing elit Morbi justo lacus fringilla sed malesuada sed laoreet in dolor Donec ipsum enim rhoncus vel hendrerit ac fermentum non libero Etiam id turpis Quisque dignissim nunc non porta mattis nisl pede tincidunt purus sit amet rhoncus turpis felis ut nunc In velit turpis vestibulum et pulvinar in dignissim a tortor Quisque imperdiet erat id est Pellentesque sodales imperdiet leo Suspendisse placerat Nullam vel tellus Nulla blandit augue sed pretium mollis leo libero consequat libero ut euismod velit magna vel nisl Donec posuere blandit pede Nam et nibh ac eros malesuada gravida Ut eget erat non arcu viverra eleifend Morbi porta risus vel tortor Ut massa Lorem ipsum dolor sit amet consectetuer adipiscing elit Morbi justo lacus fringilla sed malesuada sed laoreet in dolor Donec ipsum enim rhoncus vel hendrerit ac fermentum non libero Etiam id turpis Quisque dignissim nunc non porta mattis nisl pede tincidunt purus sit amet rhoncus turpis felis ut nunc In velit turpis vestibulum et pulvinar in dignissim a tortor Quisque imperdiet erat id est Pellentesque sodales imperdiet leo Suspendisse placerat Nullam vel tellus Nulla blandit augue sed pretium mollis leo libero consequat libero ut euismod velit magna vel nisl Donec posuere blandit pede Nam et nibh ac eros malesuada gravida Ut eget erat non arcu viverra eleifend Morbi porta risus vel tortor Ut massa Lorem ipsum dolor sit amet consectetuer adipiscing elit Morbi justo lacus fringilla sed malesuada sed laoreet in dolor Donec ipsum enim rhoncus vel hendrerit ac fermentum non libero Etiam id turpis Quisque dignissim nunc non porta mattis nisl pede tincidunt purus sit amet rhoncus turpis felis ut nunc In velit turpis vestibulum et pulvinar in dignissim a tortor Quisque imperdiet erat id est Pellentesque sodales imperdiet leo Suspendisse placerat Nullam vel tellus Nulla blandit augue sed pretium mollis leo libero consequat libero ut euismod velit magna vel nisl Donec posuere blandit pede Nam et nibh ac eros malesuada gravida Ut eget erat non arcu viverra eleifend Morbi porta risus vel tortor Ut massa Lorem ipsum dolor sit amet consectetuer adipiscing elit Lorem ipsum dolor sit amet consectetuer adipiscing elit Morbi justo lacus fringilla sed malesuada sed laoreet in dolor Donec ipsum enim rhoncus vel hendrerit ac fermentum non libero Etiam id turpis Quisque dignissim nunc non porta mattis nisl pede tincidunt purus sit amet rhoncus turpis felis ut nunc In velit turpis vestibulum et pulvinar in dignissim a tortor Quisque imperdiet erat id est Pellentesque sodales imperdiet leo Suspendisse placerat Nullam vel tellus Nulla blandit augue sed pretium mollis leo libero consequat libero ut euismod velit magna vel nisl Donec posuere blandit pede Nam et nibh ac eros malesuada gravida Ut eget erat non arcu viverra eleifend Morbi porta risus vel tortor Ut massa Lorem ipsum dolor sit amet consectetuer adipiscing elit Morbi justo lacus fringilla sed malesuada sed laoreet in dolor Donec ipsum enim rhoncus vel hendrerit ac fermentum non libero Etiam id turpis Quisque dignissim nunc non porta mattis nisl pede tincidunt purus sit amet rhoncus turpis felis ut nunc In velit turpis vestibulum et pulvinar in dignissim a tortor Quisque imperdiet erat id est Pellentesque sodales imperdiet leo Suspendisse placerat Nullam vel tellus Nulla blandit augue sed pretium mollis leo libero consequat libero ut euismod velit magna vel nisl Donec posuere blandit pede Nam et nibh ac eros malesuada gravida Ut eget erat non arcu viverra eleifend Morbi porta risus vel tortor Ut massa Lorem ipsum dolor sit amet consectetuer adipiscing elit Morbi justo lacus fringilla sed malesuada sed laoreet in dolor Donec ipsum enim rhoncus vel hendrerit ac fermentum non libero Etiam id turpis Quisque dignissim nunc non porta mattis nisl pede tincidunt purus sit amet rhoncus turpis felis ut nunc In velit turpis vestibulum et pulvinar in dignissim a tortor Quisque imperdiet erat id est Pellentesque sodales imperdiet leo Suspendisse placerat Nullam vel tellus Nulla blandit augue sed pretium mollis leo libero consequat libero ut euismod velit magna vel nisl Donec posuere blandit

    Original URL path: http://www.craftymind.com/factory/guimark/FramerateHtml.html (2016-04-27)
    Open archived version from archive

  • WPF - Silverlight Demo
    0 fps

    Original URL path: http://www.craftymind.com/factory/guimark/FramerateSilverlight.html (2016-04-27)
    Open archived version from archive

  • Index of /factory/guimark/source
    modified Size Description Parent Directory GUIMark Flex3 source 19 May 2008 23 47 44K GUIMark HTML4 source 19 May 2008 23 40 205K GUIMark Java5Swing s 19 May 2008 23 43 83K GUIMark Silverlight1 19 May 2008 23 40 44K

    Original URL path: http://www.craftymind.com/factory/guimark/source/ (2016-04-27)
    Open archived version from archive

  • Index of /factory/guimark2/assets
    Feb 2010 21 20 1 9K cannon6 png 10 Feb 2010 21 20 1 9K cannon7 png 10 Feb 2010 21 21 1 9K cannon8 png 10 Feb 2010 21 21 1 8K explosion 23 Mar 2010 18 24 grasstexture jpg 11 Feb 2010 21 37 35K grasstile png 21 Mar 2010 05 10 17K groundtile png 21 Mar 2010 05 11 6 1K lighthouse png 21 Mar 2010 15

    Original URL path: http://www.craftymind.com/factory/guimark2/assets/ (2016-04-27)
    Open archived version from archive



  •