乙個yuv轉bmp的程式

2021-06-06 10:57:26 字數 3872 閱讀 8605

在黑客中國上找到的,執行除錯後,可以使用,**如下:

#include "stdafx.h"

#include

#include

#include

#include

#include

#define byte unsigned char

#define bool bool

#define dword unsigned long

#define false 0

#define true 1

byte *pyuvbuf, *prgbbuf;

//#define yuv_size 84480l+21120+21120

//#define rgb_size image_width*image_height*3l

//#define yuvfilename "c:\\pict.yuv"

//#define bmpfilename "c:\\pict.bmp"

#define yuv_size 1536l

#define image_width 32l

#define image_height 32l

#define rgb_size image_width*image_height*3l

#define yuvfilename "gta10.bin"

#define bmpfilename "pp0.bmp"

*/long u[256], v[256], y1[256], y2[256];

dword image_width=1;

dword image_height=1;

dword yuv_size=0;

dword rgb_size=0;

char yuvfilename[max_path];

char bmpfilename[max_path];

void makeconversiontable()

if ((i % 2 == 0))

return true;

}bool allocatebuffers()

bool readyuvfile()

//else

// printf( "open yuv file: %s\n", yuvfilename );

if ((count=_read(fp, pyuvbuf, yuv_size)) != yuv_size)

//else

// printf( "read yuv file ok\n");

_close(fp);

return true;

}bool writebmpfile()

//else

// printf( "create bmp file: %s\n", bmpfilename );

bmpheader.bftype = 'mb';

bmpheader.bfsize = rgb_size + sizeof(bitmapfileheader) + sizeof(bitmapinfoheader);

bmpheader.bfreserved1 = 0;

bmpheader.bfreserved2 = 0;

bmpheader.bfoffbits = sizeof(bitmapfileheader) + sizeof(bitmapinfoheader);

bmpinfo.bmiheader.bisize = sizeof(bitmapinfoheader);

bmpinfo.bmiheader.biwidth = image_width;

bmpinfo.bmiheader.biheight = image_height;

bmpinfo.bmiheader.biplanes = 1;

bmpinfo.bmiheader.bibitcount = 24;

bmpinfo.bmiheader.bicompression = bi_rgb;

bmpinfo.bmiheader.bisizeimage = rgb_size;

bmpinfo.bmiheader.bixpelspermeter = 0;

bmpinfo.bmiheader.biypelspermeter = 0;

bmpinfo.bmiheader.biclrused = 0;

bmpinfo.bmiheader.biclrimportant = 0;

if ((count=fwrite(&bmpheader, 1, sizeof(bitmapfileheader), fp)) != sizeof(bitmapfileheader))

printf( "write bmp file header failed: count=%d\n", count);

//else

// printf( "write bmp file header ok: count=%d\n", count);

if ((count=fwrite(&(bmpinfo.bmiheader), 1, sizeof(bitmapinfoheader), fp)) != sizeof(bitmapinfoheader))

printf( "read bmp file info failed: count=%d\n", count);

//else

// printf( "read bmp file info ok: count=%d\n", count);

if ((count=fwrite(prgbbuf, 1, rgb_size, fp)) != rgb_size)

printf( "write bmp file data failed: count=%d\n", count);

//else

// printf( "write bmp file data ok: count=%d\n",count);

fclose(fp);

return true;

}// gets command line arguments.

// returns: true on success, false on error

// returns index of the first unread argument in *pi

bool getargs(int argc, char* argv)

#define argis(s)  (!strcmp(argv[i]+1, s))

while(*(argv[++i]) == '/') // get parameters - must start with '/'

else

if ((*(argv[i]+1) == 'v') || (*(argv[i]+1) == 'v'))

}if ((image_width % 16 != 0) || (image_height % 16 != 0))

yuv_size = image_width*image_height + image_width*image_height/2;

rgb_size = image_width*image_height*3l;

strcpy(yuvfilename, argv[3]); // next argument is a input file name

strcpy(bmpfilename, argv[4]); // next argument is a output file name

return true;

}int main(int argc, char* argv)

else}}

freebuffers();

//printf("\n*** press return key to continue.\n");

//scanf("%c", &cwait);

return 0;

}

yuv420 轉bmp的方法

yuv420 轉bmp的方法 我找到了乙個c寫的exe 但是c的水平我實在是不敢去修改那個原始碼,所以我乾脆就呼叫這個dll,在c 裡建立了下面這個類,然後呼叫 y2b.exe 來轉換,而且不會顯示出來那個黑屏.要知道怎麼回事,就看 吧 呵呵.using system using system.co...

乙個tif轉bmp的示例

本文受了 的啟發。bmp的格式是rgbrgb.排列下來的,每個畫素的三個分量靠在一起,描述完乙個畫素,接著描述下乙個畫素。tif的格式更多樣。通常的格式也是bgrbgr.次序與bmp相反 排列下來的,但偶爾有一些tif檔案採用rrrrrr.ggggg.bbbbb.的安排。還有的tif檔案內容是壓縮過...

第乙個OC程式 轉

說明 這個objective c專題,是學習ios開發的前奏,也為了讓有物件導向語言開發經驗的程式設計師,能夠快速上手objective c。如果你還沒有程式設計經驗,或者對objective c ios開發不感興趣,請忽略。學習本專題之前,建議先學習c語言專題。因為我們只是學習oc語法,還未正式進...