X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=avi2swf%2Fvideoreader_vfw.cc;h=b40c378b5f287081f2eff54d468618707fb372e7;hb=092631551746b263c12bb6c976af118fe8a0c1a9;hp=2e0c787df9018028143feaf7197069d98bd4ba11;hpb=82a546b2f8df7f6533d8bdfb4b45e9729bc49159;p=swftools.git diff --git a/avi2swf/videoreader_vfw.cc b/avi2swf/videoreader_vfw.cc index 2e0c787..b40c378 100644 --- a/avi2swf/videoreader_vfw.cc +++ b/avi2swf/videoreader_vfw.cc @@ -62,7 +62,7 @@ static bool videoreader_vfw_eof(videoreader_t* vr) return (i->video_pos >= i->video_end); } -static int bitmap_to_rgba(BITMAPINFOHEADER*bi, void*buffer, const int dest_width, const int dest_height) +static int bitmap_to_rgba(BITMAPINFOHEADER*bi, void*buffer, const int dest_width, const int dest_height, int flip) { UCHAR*data = (UCHAR*)(bi+1); // actual bitmap data starts after the header @@ -89,14 +89,14 @@ static int bitmap_to_rgba(BITMAPINFOHEADER*bi, void*buffer, const int dest_width int linex = ((bytesperpixel/8)+3)&~3; memset(dest, 255, dest_width*dest_height*4);//pre-fill alpha channel - int starty = i->flip? 0 : dest_height-1; - int endy = i->flip? dest_height-1 : 0; - int yinc = i->flip? 1 : -1; + const int starty = flip? 0 : dest_height-1; + const int endy = flip? dest_height : -1; + const int yinc = flip? 1 : -1; if(bi->biBitCount==1) { UCHAR*img = data; int y; - for(y=starty;y<=endy;y+=yinc) { + for(y=starty;y!=endy;y+=yinc) { UCHAR*line = &img[linex*y]; int x; for(x=0;xbiClrUsed*4]; UCHAR*pal = data; int y; - for(y=starty;y<=endy;y+=yinc) { + for(y=starty;y!=endy;y+=yinc) { UCHAR*line = &img[linex*y]; int x; for(x=0;xbiClrUsed*4]; UCHAR*pal = data; int y; - for(y=starty;y<=endy;y+=yinc) { + for(y=starty;y!=endy;y+=yinc) { UCHAR*line = &img[linex*y]; int x; for(x=0;xbiBitCount==24) { UCHAR*img = data; int y; - for(y=starty;y<=endy;y+=yinc) { + for(y=starty;y!=endy;y+=yinc) { UCHAR*line = &img[linex*y]; int x; for(x=0;xbiBitCount==32) { UCHAR*img = data; int y; - for(y=starty;y<=endy;y+=yinc) { + for(y=starty;y!=endy;y+=yinc) { UCHAR*line = &img[linex*y]; int x; for(x=0;xwidth, i->height)) { + if(!bitmap_to_rgba(bi, buffer, i->width, i->height, i->flip)) { fprintf(stderr, "couldn't convert bitmap to RGBA.\n"); return 0; }