ijl yuv422转jpeg

Ijlinteljpg压缩库,函数如下:

 

//ijl 库压缩

//ijl

BOOL BeginIJL(JPEG_CORE_PROPERTIES *jcprops)

{

     IJLERR   jerr = IJL_OK;

     jerr = ijlInit(jcprops);

     if(jerr != IJL_OK){

         printf("INIT IJL ERR -- %s\n", ijlErrorStr(jerr));

         return FALSE;

     }

     return TRUE;

}

 

void EndIJL(JPEG_CORE_PROPERTIES *jcprops)

{

     ijlFree(jcprops);

     return;

}

 

//

BOOL EncodeToJPEGBuffer(

                            JPEG_CORE_PROPERTIES *jcprops,

                            BYTE *lpRawBuffer,

                            DWORD dwWidth,

                            DWORD dwHeight

                            BYTE *lpJPEGBuffer,

                            DWORD *lpjpgBufferSize,

                            int quality)

{

     BOOL bres;

     IJLERR   jerr = IJL_OK;

     DWORD    rawBufSize;

     //JPEG_CORE_PROPERTIES jcprops;

 

     bres = TRUE;

     rawBufSize = dwWidth * dwHeight * 2;

 

     jcprops->DIBWidth = dwWidth;

     jcprops->DIBHeight = dwHeight;

     jcprops->DIBBytes = lpRawBuffer;

     jcprops->DIBPadBytes = 0;

     jcprops->DIBChannels = 3;

     jcprops->DIBColor =IJL_YCBCR;

     jcprops->DIBSubsampling = IJL_422;

 

     jcprops->JPGWidth = dwWidth;

     jcprops->JPGHeight = dwHeight;

     jcprops->JPGFile = NULL;

     jcprops->JPGBytes = lpJPEGBuffer;

     jcprops->JPGSizeBytes = rawBufSize;

     jcprops->JPGChannels = 3;

     jcprops->JPGColor = IJL_YCBCR;

     jcprops->JPGSubsampling = IJL_422;

     jcprops->jquality = quality;

 

     jerr = ijlWrite(jcprops, IJL_JBUFF_WRITEWHOLEIMAGE);

     if(jerr != IJL_OK){

         printf("ijlWrite() failed -- %s\n", ijlErrorStr(jerr));

         bres = FALSE;

         goto ENCODE_ERROR;

     }else{

         *lpjpgBufferSize = jcprops->JPGSizeBytes;

     }

ENCODE_ERROR:

     //ijlFree(&jcprops);

     return bres;

}

 

 

//

int CImgXXX::yuv422_to_jpeg_ijl(unsigned char *data, int image_width, int image_height, char *filename, int quality)

{

 

     DWORD len = 0;

     JPEG_CORE_PROPERTIES   jcprops;

     FILE *fp = NULL;

     BYTE *out;

 

     out=(BYTE *)malloc(image_width*image_height*2);

 

     if(!BeginIJL(&jcprops)) return 0;

 

     if(!EncodeToJPEGBuffer(&jcprops, data, image_width, image_height, out, &len,quality))

         printf("encode error\n");

     else{

         printf("encode %d\n", len);

         if ((fp = fopen(filename, "wb"))==NULL)

         {

              fprintf(stderr, "can't open %s/n", filename);

              return -1;

         }

         fwrite((void *)out, 1, len, fp);

         fclose(fp);

     }

 

     fclose(fp);

 

     EndIJL(&jcprops);

 

     return 0;

 

}

 

//

void CImgXXX::SaveYuv2Jpg(void *pYuvBuf,int image_width,int image_height)

{

     CString str;

     SYSTEMTIME st;

     GetLocalTime(&st);

     CString strtime;

     strtime.Format("%4d.%2d.%2d-%2d.%2d.%2d-%3d",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond,st.wMilliseconds);

 

     str="./pic/";

     str+=strtime;

     str+=".jpg";

 

 

     //yuv422_to_jpeg((unsigned char *)pYuvBuf,image_width,image_height,str.GetBuffer(0),JPEG_QUALITY);

     yuv422_to_jpeg_ijl((unsigned char *)pYuvBuf,image_width,image_height,str.GetBuffer(0),JPEG_QUALITY);

 

     return;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值