I think the upload has ruined the frames. I'll try another gif tomorrow.

On Saturday, 21 January 2017 16:57:15 UTC, andrey mirtchovski wrote:
>
> I see only a single frame in your source file. I ran your program on 
> another gif and got the expected result: 
>
> http://i.imgur.com/HOnlU1q.gif 
> http://i.imgur.com/GnSUHQ1.gif 
>
> On Sat, Jan 21, 2017 at 8:54 AM, kalekold via golang-nuts 
> <golan...@googlegroups.com <javascript:>> wrote: 
> > Hi, 
> > 
> > I'm trying to draw some text on an animated gif and I'm having a few 
> > problems. 
> > 
> > I have a source gif (attached as fire.gif) which I can decode fine and 
> pass 
> > the frames to the drawing lib. 
> > The problem occurs when I'm trying to replace the original frames with 
> ones 
> > I've modified. I always seem to get the same result (see attached 
> out.gif). 
> > The text seems to be drawn fine but the other frames which contain the 
> > animation seem to be missing. 
> > 
> > Here's the code: 
> > 
> > package main 
> > 
> > import ( 
> >  "image" 
> >  "image/draw" 
> >  "image/gif" 
> >  "log" 
> >  "os" 
> > 
> > 
> >  "github.com/fogleman/gg" 
> > ) 
> > 
> > func main() { 
> > 
> >     in, err := os.Open("/home/gary/Desktop/fire.gif") 
> >     if err != nil { 
> >         log.Fatalln(err) 
> >     } 
> >     defer in.Close() 
> > 
> >     decoded, err := gif.DecodeAll(in) 
> >     if err != nil { 
> >         log.Fatalln(err) 
> >     } 
> > 
> >     for x := 0; x < len(decoded.Image); x++ { 
> >         frame := decoded.Image[x] 
> >         ctx := gg.NewContextForImage(frame) 
> >         ctx.SetHexColor("#FFF") 
> >         ctx.DrawStringWrapped("Lorem ipsum dolor sit amet", 10, 10, 0, 
> 0, 
> > 500, 1.4, gg.AlignLeft) 
> > 
> >         palImg := image.NewPaletted(frame.Bounds(), frame.Palette) 
> >         draw.FloydSteinberg.Draw(palImg, frame.Bounds(), ctx.Image(), 
> > image.ZP) 
> > 
> >         decoded.Image[x] = palImg 
> >     } 
> > 
> >     out, err := os.Create("/home/gary/Desktop/out.gif") 
> >     if err != nil { 
> >         log.Fatalln(err) 
> >     } 
> >     defer out.Close() 
> > 
> >     err = gif.EncodeAll(out, decoded) 
> >     if err != nil { 
> >         log.Fatalln(err) 
> >     } 
> > } 
> > 
> > 
> > Any ideas how to compile the changed frame to give me the correct 
> output? 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "golang-nuts" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to golang-nuts...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to