91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

可用,NV21圖像,1920*1280,可通過改變變量值換成別的尺寸的圖像,縮放應該為2的倍數

資源截圖

代碼片段和文件信息

//?NV21OperationC.cpp?:?Defines?the?entry?point?for?the?console?application.
//

#include?“stdafx.h“

#include?
#include?
#include?
#include?
#include?

#include?
#include?

#define?max?255
#define?min?0
#define?NV21?100

using?namespace?std;

typedef?struct?_tag_yuvImage{
int imageFormat;
int width;
int height;
unsigned?char* image[2];
int?pitch[2];
}YUV_Image?*PYUV_Image;

int?readYUVImage(const?char*?pFileFullPath?PYUV_Image?pImgDest)
{
printf(“readYUVImage?begin?\n“);
if?(pFileFullPath?==?NULL?||?pImgDest?==?NULL){
printf(“readYUVImage?error?1?\n“);
return?-1;
}

int?width?=?1920;
int?height?=?1280;

pImgDest->imageFormat?=?NV21;
pImgDest->width?=?width;
pImgDest->height?=?height;
pImgDest->pitch[0]?=?pImgDest->width;
pImgDest->pitch[1]?=?pImgDest->width;

int?result?=?0;
int?iamgeSize?=?0;
if?(pImgDest->imageFormat?==?NV21)
iamgeSize?=?pImgDest->pitch[0]?*?height?+?pImgDest->pitch[1]?*?(height/2);
else
printf(“Exception:The?input?image?pixel?format?is?not?NV21“);

pImgDest->image[0]?=?(byte*)malloc(iamgeSize);
if?(pImgDest->image[0]?==?NULL){
printf(“Allocation?of?memory??out?of?memory“);
result?=?-1;
}

if?(pImgDest->imageFormat?==?NV21)
pImgDest->image[1]?=?pImgDest->image[0]?+?(pImgDest->width)?*?(pImgDest->height);
else{
printf(“The?input?image?pixel?format?is?not?NV21“);
result?=?-1;
}

int?size?=?-1;
FILE*?fp?=?fopen(pFileFullPath?“rb“);
if?(NULL?!=?fp){
fseek(fp?0L?2);
size?=?ftell(fp);
fseek(fp?0L?0);
if?(size? printf(“ReadDataFromFile?filesize? result?=?-1;
}
fread(pImgDest->image[0]?1?iamgeSize?fp);
}
if?(NULL?!=?fp)
fclose(fp);

if?(size?==?iamgeSize)
result?=?0;

return?result;
}

int?saveYUVImage(const?PYUV_Image?pframe?const?char*?pSrcFilePath)
{
printf(“Start?saving?OffScreen\n“);

int?result?=?-1;
if?(pframe?==?NULL?||?pSrcFilePath?==?NULL)
return?-1;

FILE*?fp?=?NULL;
fp?=?fopen(pSrcFilePath?“wb“);
if?(NULL?==?fp){
printf(“Save?filepath?is?invalid“);
result?=?-1;
}
else{
do{
int?iamgeSize?=?0;
if?(pframe->imageFormat?==?NV21){
fwrite(pframe->image[0]?1?pframe->pitch[0]?*?pframe->height?fp);
fwrite(pframe->image[1]?1?pframe->pitch[1]?*?(pframe->height/2)?fp);
}
}?while?(false);
}
return?result;

}
int?MyRotate(const?PYUV_Image?pframe?int?degree?PYUV_Image?pOutframe)
{
int?result?=?-1;
if?(pframe?==?NULL?||?pOutframe?==?NULL)
return?-1;
if?(pframe->imageFormat?!=?NV21?||?pOutframe->imageFormat?!=?NV21){
printf(“Rotate?image?failed?the?image?pixel?format?is?not?NV21“);
return?-1;
}
int?width?=?pframe->width;
int?height?=?pframe->height;

int?height2?=?(int)(height*1.5);
int?kPosition?=?0;
switch?(degree){
case?90:
for?(int?i?=?width?-?1;?i?>=?0;?--i){
for?(in

評論

共有 條評論