ShowMassage("#include
void
{
FILE *fp; /*定义一个文件指针*/
int i;
if(fp==NULL) /*判断文件是否打开成功*/
puts("File open error");/*提示打开不成功*/
i=fclose(fp); /*关闭打开的文件*/
if(i==0) /*判断文件是否关闭成功*/
printf("O,K"); /*提示关闭成功*/
else
puts("File close error");/*提示关闭不成功*/
//播放的视频尺寸为176 X 144,建立一个frame的缓冲区
unsigned char *imgYUV = new unsigned char [176*144*3];//176*144=25344
double Y,U,V,C,D,E;
unsigned char R,G,B;
int width,height,j,k;
//得到绘图句柄
CClientDC dc (this);
width=176;
height=144;
//打开文件
fp=fopen("foreman_part_qcif_444.yuv", "rb"); /*打开当前目录名为foreman_part_qcif_444.yuv的文件只读*/
//读取文件,每次读一桢
while (fread(imgYUV, 1, 25344*3, fptr) > 0 ){
for(k=0; k 235) /* too bright (ADDED) */
{
outputbits[i] = 0; // 色调未被定义 outputbits[i 1] = 0; // 颜色的饱和度为0 }
else /* chromatic case */
{
if (intensity <= 127) /* bottom cone (dark) */
saturation = (255 * (max - min)) / (max min);
else /* top cone (bright) */
saturation = (255 * (max - min)) /
(512 - max - min);
if ((saturation < 0) || (saturation > 255))
OutputText("Problem with saturation\n");
outputbits[i 1] = (unsigned char) saturation; if (r == max)
hue = (60 *(g -b))/(max - min);
/* 颜色介于黄色与品红之间 */
else if (g == max)
hue = 60*2 (60*(b-r))/(max-min);
/* 颜色介于青色与黄色之间 */
else
hue = 60*4 (60*(r-g))/(max-min);
/* 颜色介于品红与青色之间 */
if (hue < 0)
hue = hue 360;
if ((hue < 0) || (hue > 360))
OutputText("Problem with hue\n");
temp = (255 * hue) / 360;
outputbits[i] = (unsigned char) temp;
}
}
return(outputbits);
}
//关闭文件
fclose(fptr);
} ")
这是我写的大概的转换算法,后面关于RGB转HSI的算法还不确定,可能有很多错误。
请帮我看看,这样写是否可以。
谢谢 我是菜菜鸟 發表人 - 艾薇 於 2005/05/25 19:58:28