How Do I Load An Animated GIF Into PictureBox Control From Byte Array?

I'm having a problem with loading an animated GIF int a picturebox control in a C# program after it has been converted to a base64 string, then converted to a byte array, then written to binary, then converted to a base64 string again, then converted to
a byte array, then loaded into a memory stream and finally into a picturebox control.
Here's the step-by-step code I've written:
1. First I open an animated GIF from a file and load it directly into a picturebox control. It animates just fine.
2. Next I convert the image in the picturebox control (pbTitlePageImage) to a base64 string as shown in the code below:
                if (pbTitlePageImage.Image != null)
                    string Image2BConverted;
                    using (Bitmap bm = new Bitmap(pbTitlePageImage.Image))
                        using (MemoryStream ms = new MemoryStream())
                            bm.Save(ms, ImageFormat.Jpeg);
                            Image2BConverted = Convert.ToBase64String(ms.ToArray());
                            GameInfo.TitlePageImage = Image2BConverted;
                            ms.Close();
                            GameInfo.TitlePageImagePresent = true;
                            ProjectNeedsSaving = true;
3. Then I write the base64 string to a binary file using FileStream and BinaryWriter.
4. Next I get the image from the binary file using FileStream and BinaryReader and assign it to a string variable. It is now a base64 string again.
5. Next I load the base64 string into a byte array, then I load it into StreamReader and finally into the picturebox control (pbGameImages) as shown in the code below:
byte[] TitlePageImageBuffer = Convert.FromBase64String(GameInfo.TitlePageImage);
                        MemoryStream memTitlePageImageStream = new MemoryStream(TitlePageImageBuffer, 0, TitlePageImageBuffer.Length);
                        memTitlePageImageStream.Write(TitlePageImageBuffer, 0, TitlePageImageBuffer.Length);
                        memTitlePageImageStream.Position = 0;
                        pbGameImages.Image = Image.FromStream(memTitlePageImageStream, true);
                        memTitlePageImageStream.Close();
                        memTitlePageImageStream = null;
                        TitlePageImageBuffer = null;
This step-by-step will work with all image file types except animated GIFs (standard GIFs work fine). It looks like it's just taking one frame from the animation and loading it into the picturebox. I need to be able to load the entire animation. Does any of
the code above cause the animation to be lost? Any ideas?

There is an ImageAnimator so you may not need to use byte array instead.
ImageAnimator.Animate Method
http://msdn.microsoft.com/en-us/library/system.drawing.imageanimator.animate(v=vs.110).aspx
chanmm
chanmm

Similar Messages

  • How do I import animated gifs into Premiere with a transparent background?

    I have an animated gif that I got from the internet, and I'm trying to import it into Premiere Pro with a transparent background. The gif is of a video game character standing still and blinking. Whenever I import it, it always has a white background, so I need help on how to change that.
    I've gone into Photoshop and removed the white background frame by frame, making it transparent. I do this by using the magic wand tool to select the white background, then hit "delete" to turn it into that diamond grid, which means it's transparent. I then select File -> Save for Web. I preview every frame, and it shows that the backgrounds are transparent. I save it as a gif. But when I import it into Premiere Pro, the white background is still there.
    I've read many forums online about people trying to import images into Premiere Pro with a transparent background, but none of them have explained how to do it specifically for animated gifs. Every answer has always been "export the image as a png, that'll work", and sure enough, I exported a few frames of the gif as pngs, and those few frames had transparent backgrounds in Premiere Pro. But I don't want a png because those aren't animated sequences, those can only be still images. I need to export it as a gif so that it will remain animated, but gif files always have that dreaded white background in Premiere Pro.
    I suppose I could export every frame as a png, import each of those frames into Premiere Pro, then string all the frames together and tweak them so they'll be functionally identical to the animated gif, but that would take forever. I'm making a video project and I need numerous animated gifs to work with, so I don't want to do that with every single one of them. I'm looking for a way to simply import the gifs into Premiere Pro and be done with it. If there is any way to do this, please help me.
    -Robert

    faind on gif transparency and other cartoon animation problems : Adobe After Effects
    " The reason: GIFs don't support alpha channels. Instead, their file structure assigns a certain color value to be read as totally transparent. There aren't any degrees of transparency as you find in graphics formats that do support alpha channels.
    To use an animated gif in AE, you'd first have to create the areas of transparency, then convert the series of images into a graphics format that supports alpha channels, and there are a bunch: PICT, TIFF, TARGA or PNG, to name a few."

  • How can I edit an animated GIF?

    is there a way to add a animated GIF into your work, when I try to add one I am told that it will be a single layer. I downloaded a GIF from the web and trying to incorparate it into a web site header.

    Well, you are in luck, sort of. You have all the apps needed to create an animated gif. However that does not mean that the image you download was already or not. It could be a single image.
    A couple of things to go over
    1) When downloading from the net make sure you have permission to use that image before sharing with the public, as the image is protected by copyright laws in the US. (Images that state - Permission to use commercially, copyright free, common law licence - Generally are meant to share with the general public, granted that you post somewhere who you got the image from(the Least anyone can do it give credit where credit is due)
    2)Since you have the Master Collection or the CS4 Master Suite, you have every app that is need to create your own works of art. Photoshop, After Effects, Premeire pro are all capable of creating animated gifs. With the latter two being easier than photoshop.
    Since you have CS4 photoshop and this is the photoshop forum, we will keep it there.
    The version of Photoshop that comes in the master suite is the extended version of photoshop which is require for most of the animations it can do. Though, think and am not certain that the standard version can create animated gif files.
    OK, ok we got a lot of mumbo jumbo above so lets get into how to create an animated gif.
    First we need to determine if we are editing an animated gif or creating one from scratch. To load an animated gif all you need to do is file>open then select the file. Simple enough.
    The file will place each frame onto its own layer and if you have the animation panel open (If not select Windows>Animation ) Each frame will be placed there as well.
    Lets say we are going to edit a frame or better yet introduce a new frame. In the upper right hand corner of the animation panel is a small icon. Clicking it will pop up a menu. In that menu select delete animation. Don't worry your layers are safe, it only removes the frames from the animation panel.
    Now you can either change something in one of the layers or add a layer where you want the frame intoduced.
    When you are done you can select that same icon in the animation panel to pop up the menu and select Make frames from layers This will place all the layers back into the animation panel. This has to happen in order to save an animated gif.
    You can now use the File>save to web or File>Save to web and devices (This optiuon changed during one of the version, I don't recall so both are listed or look for something close to that)
    Select Gif for the format then the save button, where you can choose a location and file name. It will automatically add a hyphen between any words that normally are spaces for the web.
    OK, If you read the above, you probably alread realize how to create one from scratch. Just add a new layer for each frame and follow the steps above to add it to the animation panel and save for web.
    I know it sounds like a lot, but once you have done it a few times, it actually fairly simple.
    OK, Bonus round - What about After Effects and Premeire Pro?
    Well both of those apps Use a timeline instead of frames. Which makes them much simpler and more powerful for animations, since that is what they are dedicated to do.
    It is as simple as open the gif file, edit it, save it, done.
    I won't go into how the timeline works as that would require a long , long post. But once you understand it, it is much quicker and can do way more feature wise.
    One last thing, play around with it and see what it can do before commiting time to creating or editing a gif. It goes much easier once you get the hang of it.
    If you have any questions, issues, etc. just post away...
    Well, I got to go, I hope this helps.

  • How do you make an animated gif activate when a corresponding button is selected?

    I am working on a DVD menu using Photoshop and Encore. I currently have a map as a background and a gif animation of a radar ping. The radar ping has transparent parts so that it shows up in front of the map it will be placed on. I want the radar ping gif to animate when it is selected, but I cannot make it animate. When I tried to place the animated gif into the DVD, it became a static image with 50 layers, instead of an animation with 50 frames. When I replaced the gif with a static image, it still caused problems because when I made it into one of the button's highlights, the button overlapped the other buttons, causing those to highlight as well.
    Summary: Ideally, I want to add various gifs that will activate when the corresponding menu/chapter buttons are selected.
    Failing that, I would be happy just to know how to add an animated gif to my DVD menu background.

    You have two problems. The first is that an animated gif has no special status in DVD authoring. It is an anmiation. How do you get animations into a DVD project? You import them as movies - either as assets that get puit on timelines, or assets that become part of a motion background.
    Yes, Encore has a special feature of making animated thumbnails, but this is  just a fancy way of putting thumbnail-sized bits of video into a video background of a menu.
    I think you resolve the animated gif issue if you convert it to a video format Encore understands.
    http://helpx.adobe.com/encore/using/importing-assets.html#supported_file_formats_for_impor t
    The second issue is that you want a button highlight to be an animation. Also not part of the DVD spec or what Encore will do. You can fake this, by having a button autoactivate and to go to a different menu that has the animation for that button as part of the background.  You create as many menus as you have buttons with that characteristic.
    Note that a mouseover won't autoactivate, so this doesn't work on a  computer the way solme users would like.
    Scripting is a way some authoring applications can handle such things, but Encore does not provide scripting.

  • Load an Animated GIF

    Hi everybody!
    I'm not too experienced in using Java2D, and I've just started build my Canvas. I've got to load an Animated Gif. it is loaded and the animation starts, but the Canvas area starts flickering every frame loop. Now I'm loading the gif with ImageIcon, but I was seeing that maybe the best way to avoid this problem is the MediaTracker Class
    is there anybody who can help me understand better this class, or tell me how to avoid the "flickering"??
    thank you&bye! Milla

    The flickering is because you are not double buffering.
    Have a search of these forums, you will find it covered in alot of Threads.

  • How do I add an animated gif to mail?

    How do I add an animated gif to mail and still have the animation active

    Dj
    I found this complete mail tutorial. Hope this will help you with unread messages.
    Regards,
    Joseph

  • How can I load an external SWF into a movie clip that's inside other movie clip?

    Hi.
    I creating my first flash (actionscript 3.0) website but I'm
    stuck with a visual effect I want to create.
    I have a window on my website called contentWindow. Every
    time you click a button this window is supposed to leave the stage,
    load the requested content and return to the stage.
    The sliding window is a movie clip with 83 frames, 21 to
    enter the stage, 21 to leave the stage again, 20 for nothing (its
    just to simulate the loading time) and 21 to return to the stage.
    Now my goal is, when the user clicks on a navigation button,
    the window exits the stage, loads an external SWF with the content,
    and then returns to the stage.
    I've the "window" movie clip with an instance name of
    "contentWindow". Inside there is another movie clip with an
    instance name of "contentLoader". The content that the user
    requested should appear inside the "contentLoader".
    Now, when the contentWindow leaves the stage, I get this
    error message:
    quote:
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at rwd_fla::MainTimeline/trigger()
    If I switch
    "contentWindow.contentLoader.addChild(navLoader);" for
    "contentWindow.addChild(navLoader);" it works fine, but the
    external SWF doesn't move with the window.
    How can I load an external SWF into a movie clip that's
    inside other movie clip?

    Hi,
    Recently, I have been putting together a flash presentation.
    And I am just wondering if the following might help you, in your
    communication with the said swf file:
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    onComplete);
    function onComplete(event:Event):void
    event.target.content.thinggy_mc.y -= 100;
    Not the best example, but this allows you to target a mc
    within an external swf file. I think if you look up this code, you
    will have an answer ;)
    Kind Regards,
    Boxing Boom

  • How do you load an AS2 swf into AS3?

    I think this is the way around my dilemma. How do you load and AS2 .swf into an AS3 file?
    thanks again!
    Steve

    check that code in your last thread:
    What is the  code to load a .swf file in AS3 on the same layer?

  • How do you load exs. format files into EXS 24 sampler?

    How do you load EXS24 format files into the EXS24 sampler? the only format I can load directly is aiff and wav. can't find any posts addressing this question? please help

    You don't load them in, you need to put them in:
    *System/users/your user name/library/application support/logic/Sampler instruments*
    Restart Logic if it's running, they will then appear in the EXS library.

  • How do I load new kuler themes into photoshop CS6

    How do I load new kuler themes into photoshop CS6?
    That's it, plus the Kuledr desktop app (Mac version) always gives me a Kuler Klash?

    Are you sure it is not stand alone?  Google Sketchbook Express & Photoshop CS6, and you get no meaningful hits.  Google just Sketchbook Express and it brings up links than say stuff like:
    If you've just switched to Mac and are looking for a replacement for MS Paint, then SketchBook Express is a fun drawing application that's suitable for everything from a quick doodle to professional sketching.
    SketchBook Express uses professional-grade tools that enable you to produce some highly impressive results. The streamlined interface allows for what is known as "gesture-based marking menus" which mean that different tools are available to you at the click of a mouse. However, to get the most out of SketchBook Express, you'll need a pen and tablet device.
    There are many preset tools,
    Read more 
    Pros 
    Suitable for doodling and professional sketching
    Good alternative to MS Paint
    Easy to switch main tools
    Cons 
    Best to be used with pen and tablet device
    May not be fully comptaible with all tablets
    Lacks advanced sketching tools

  • How do I load a sd card into my imac?

    How do I load a sd card into my imac?

    I have a brand new iMac.  Won't recognize my card.
    Mac won't recognize my camera either
    Won't recognize my HD video camera.
    Somehow I can't believe my windows PC has done better on pictures and video.  How is that possible?

  • How do I export an animated GIF from Premiere CC?

    How do I export an animated GIF from Premiere CC?
    I dont see an Animated codec option

    Hi Nick
    Believe me I STARTED there.
    I wouldnt post this message if I didnt try there first.
    I do not see Animated GIF as a codec option.
    Please walk me through the step by step process of how you got this.
    Because it is not as obvious as you're making it out to be.
    Further more perhaps a certain format has to be selected for Animated GIF options to appear?
    YES I AM ON CC version too. thanks!

  • How combine a jpeg image & animated gif image & save  it as GIF ?

    i have an jpeg image, & also aminated gif image, how do i place the animated gif image over (in the center of the image) a jpeg image & save it as gif file ??

    First thing you need to do is stop thinking in terms of file formats once the files are in photoshop they are all the same. The exception being vector vs raster. But in this instance the process is rteally the same so 6 on one hand a half a dozen on the other. Or as some would say Tomatoe, tomahtoe(mispelled on purpose).
    The jpeg I would assume is the background image and the gif image is the fore ground object. Open the jpeg, and then place the gif file. As long as the fore ground object has transparency, your job is pretty much done. If not, then it will be up to you to mask what you want to keep vs what you don't and apply that selection to the foregrounds layer as a mask.
    Google the net or skim the users manual for the keywords - mask, selections, quickmask, pen tool, paths. Each of these can in one way or another take care of your issue.
    It would be worth your time to also go through the numerous videos about photoshop and see how its done.
    Either go to adobe tv,
    Itunes podcasts
    or one of the following web sites:
    http://kelbytv.com/
    http://creativesuitepodcast.com/

  • How can i load a 8cm dvd into my drive ??

    Hi
    I am i being a little thick .... I have a sony handycam and it has 8cm dvd that i record onto.
    How can i load these dvd's into my macbook pro, notebook ??
    Please help
    Many thanks
    Michelle

    You can't. The MBP's slot-loading optical drive doesn't support nonstandard-sized discs at all.
    If the camcorder has a USB or FireWire output, you may be able to use that to transfer videos from it to the computer. Alternatives include buying a tray-loading external optical drive that can handle the oddball discs, or transferring the videos to a computer that has an internal tray-loader, then transferring them to the Mac from the other computer wirelessly, via a USB flash drive or external hard drive, or via a burned standard-sized disc.

  • How do I load photos & Music to my iPhone 3G from iPhoto /iTunes?

    How do I load photos & Music to my iPhone 3G from iPhoto /iTunes?
    If I want to use photos as wallpaper on the phone do they have to be resized or can I just load them?

    With your iphone plugged into itunes go to the tables for music, photos, etc and set to sync with the album,playlist you want.
    Sounds like you might need to read the owners manual:
    http://manuals.info.apple.com/enUS/iPhone_UserGuide.pdf

Maybe you are looking for

  • Problem in  Number range Interval in VF02

    Hi All,      I am using Number range USEREXIT for invoice creation- VF01. So, while creating invoice, userexit will trigger, as per our logic provided,system generating numbers as expected.- which is working fine. Where as, in VF02, transaction , i w

  • Non-U.S. apple online store

    i'm from the philippines and it's been a long time the apple online store came here. if i order from there, do i have to pay for whatever i order that qualifies for free shipping as-is or what is stated without additional charges? i know shipping is

  • Cannot convert between unicode and non-unicode string datatypes

      My source is having 3 fields : ItemCode nvarchar(50) DivisionCode nvarchar(50) Salesplan (float) My destination is :  ItemCode nvarchar(50) DivisionCode nvarchar(50) Salesplan (float) But still I am getting this error :  Column ItemCode cannot conv

  • Need Tables and Func Modules related to Project Systems

    Hi       I am working on a custom program that Creates Project ( CJ01) using standard Project Def.      All WBS elements of  Standard Project Template  should be copied to the newly created Project     I am not able to get any Standard Func Module wh

  • TS3694 Why am I getting error code 3194 when i try to restore my ipod?

    Why am I getting error code 3194 when I try to restore my ipod touch 4th generation