Problems converting AVFrame to gdImagePtr

From: Date: Sat, 30 May 2009 14:44:10 +0000
Subject: Problems converting AVFrame to gdImagePtr
Groups: php.gd.devel 
Request: Send a blank email to php-gd-devel+get-565@lists.php.net to get a copy of this message
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

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