linux - How to resize an image from an rgb buffer using c++ -
i have (char*)rgb buffer has data of actual image. let's actual image resolution 720x576. want resize resolution , 120x90. how can using https://code.google.com/p/jpeg-compressor/ or libjpeg ?
note: can use other library, should work in linux.
edited: video decoder decodes frame in yuv, convert rgb. these happen in buffer. need resize rgb buffer make thumbnail out of variable size.
thanks in advance
i did following achieve goal:
#define tn_width 240 #define tn_height 180 #include "jpegcompressor/jpge.h" #include "jpegcompressor/jpgd.h" #include <ippi.h> bool createthumnailjpeg(const uint8* psrc, int srcwidth, int srcheight) { int req_comps = 3; jpge::params params; params.m_quality = 50; params.m_subsampling = jpge::h2v2; params.m_two_pass_flag = false; file *fpjpegtn = fopen("resource\\jpegcompressor.jpeg","wb"); int dstwidth = tn_width; int dstheight = tn_height; int uidstbuffersize = dstwidth * dstheight * 3; uint8 *pdstrgbbuffer = new uint8[uidstbuffersize]; uint8 *pjpegtnbuffer = new uint8[uidstbuffersize]; int uisrcbuffersize = srcwidth * srcheight * 3; ippisize srcsize = {srcwidth , srcheight}; ippirect srcroi = {0, 0, srcwidth, srcheight}; ippisize dstroisize = {dstwidth, dstheight}; double xfactor = (double) dstwidth / srcwidth; double yfactor = (double) dstheight / srcheight; ippstatus status = ippiresize_8u_c3r(psrc, srcsize, srcwidth*3, srcroi, pdstrgbbuffer, dstwidth*3, dstroisize, xfactor, yfactor, 1); if (!jpge::compress_image_to_jpeg_file_in_memory(pjpegtnbuffer, uidstbuffersize, dstwidth, dstheight, req_comps, pdstrgbbuffer, params)) { cout << "failed!"; delete[] pdstrgbbuffer; delete [] pjpegtnbuffer; return false; } if (fpjpegtn) { fwrite(pjpegtnbuffer, uidstbuffersize, 1, fpjpegtn); fclose(fpjpegtn); } delete [] pdstrgbbuffer; delete [] pjpegtnbuffer; return true; }
Comments
Post a Comment