Re: [GD-DEVEL] Problems converting AVFrame to gdImagePtr

From: Date: Sat, 30 May 2009 17:39:08 +0000
Subject: Re: [GD-DEVEL] Problems converting AVFrame to gdImagePtr
References: 1  Groups: php.gd.devel 
Request: Send a blank email to php-gd-devel+get-566@lists.php.net to get a copy of this message
Hi, Do you use ffmpeg? There is an example in cvs: http://cvs.php.net/viewvc.cgi/gd/playground/ffmpeg/ Cheers, On Sat, May 30, 2009 at 4:44 PM, Udo Pokojski <udo.pokojski@t-online.de> wrote: > Hi, > > I am trying to extract single frame from a MP2-File. The frames are > extracted and saved as AVFrame. For further processing I want to convert > the AVFrame to an gdImagePtr. The conversion should be done by this > code: > ------------------------------------------------------------------------- > void SaveFrame_png(AVFrame *pFrame, int width, int height, int iFrame) { >  FILE *pFile; >  char szFilename[32]; >  int  x,y; >  gdImagePtr im; >  int *src; > >  im=gdImageCreateTrueColor(width, height); >    //gdImageInterlace(im, 1); >  src = (int *) pFrame->data[0]; >  for(y=0; y < height; y++) { >    for (x=0; x < width; x++) { >       gdImageSetPixel(im, x, y, src[x] & 0x00FFFFFF); >       //   im->tpixels[y][x] = src[x] & 0x00FFFFFF; >        } >        src += width; >  } > >  sprintf(szFilename, "frame%d.png", iFrame); >  pFile=fopen(szFilename, "wb"); >  if(pFile==NULL) >    return; >  gdImageInterlace(im,1); >  gdImagePng(im,pFile); > >  fclose(pFile); > > } > > ------------------------------------------------------------------------------ > > For a quick test, I save the gdImagePtr as a PNG-File. > The resulting file shows a kind of interlace and a multiple horizontal > shift. I have uploaded an example to > http://www.freeimagehosting.net/uploads/081ff0fcb2.png > > Write a JPG-File gives the same result. > Where is the error in this code? > > Thx, > Udo > > > > > -- > GD Devel Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Pierre http://blog.thepimp.net | http://www.libgd.org

« previous php.gd.devel (#566) next »