ffmpeg开源库,实现将bmp格式的图片编码成x264文件,并将编码好的H264文件解码保存为BMP文件。

实现将视频文件yuv格式保存的图片格式的測试,图像格式png,jpg, gif等等測试均OK

自己依据博客的代码,vs2010搭建的測试环境。资源下载

详细代码:

  1. #define _AFXDLL
  2. #include<afxwin.h>
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. #include <libavcodec/avcodec.h>
  8. #include <libavformat/avformat.h>
  9. #include <libswscale/swscale.h>
  10. void main()
  11. {
  12. CFile file[5];
  13. BYTE *szTxt[5];
  14.  
  15. int nWidth = 0;
  16. int nHeight= 0;
  17.  
  18. int nDataLen=0;
  19.  
  20. int nLen;
  21.  
  22. CString csFileName;
  23. for (int fileI = 1; fileI <= 5; fileI ++)
  24. {
  25. csFileName.Format("%d.bmp", fileI);
  26. file[fileI - 1].Open(csFileName,CFile::modeRead | CFile::typeBinary);
  27. nLen = file[fileI - 1].GetLength();
  28.  
  29. szTxt[fileI -1] = new BYTE[nLen];
  30. file[fileI - 1].Read(szTxt[fileI - 1], nLen);
  31. file[fileI - 1].Close();
  32.  
  33. //BMP bmi;//BITMAPINFO bmi;
  34. //int nHeadLen = sizeof(BMP);
  35. BITMAPFILEHEADER bmpFHeader;
  36. BITMAPINFOHEADER bmpIHeader;
  37. memcpy(&bmpFHeader,szTxt[fileI -1],sizeof(BITMAPFILEHEADER));
  38.  
  39. int nHeadLen = bmpFHeader.bfOffBits - sizeof(BITMAPFILEHEADER);
  40. memcpy(&bmpIHeader,szTxt[fileI - 1]+sizeof(BITMAPFILEHEADER),nHeadLen);
  41.  
  42. nWidth = bmpIHeader.biWidth;// 464;// bmi.bmpInfo.bmiHeader.biWidth;// ;
  43. nHeight = bmpIHeader.biHeight;//362;// bmi.bmpInfo.bmiHeader.biHeight;// ;
  44.  
  45. szTxt[fileI - 1] += bmpFHeader.bfOffBits;
  46. nDataLen = nLen-bmpFHeader.bfOffBits;
  47. }
  48. getchar();
  49. av_register_all();
  50. avcodec_register_all();
  51. AVFrame *m_pRGBFrame = new AVFrame[1]; //RGB帧数据
  52. AVFrame *m_pYUVFrame = new AVFrame[1];; //YUV帧数据
  53. AVCodecContext *c= NULL;
  54. AVCodecContext *in_c= NULL;
  55. AVCodec *pCodecH264; //编码器
  56. uint8_t * yuv_buff;//
  57.  
  58. //查找h264编码器
  59. pCodecH264 = avcodec_find_encoder(CODEC_ID_H264);
  60. if(!pCodecH264)
  61. {
  62. fprintf(stderr, "h264 codec not found\n");
  63. getchar();
  64. exit(1);
  65. }
  66.  
  67. c= avcodec_alloc_context3(pCodecH264);
  68. c->bit_rate = 3000000;// put sample parameters
  69. c->width =nWidth;//
  70. c->height = nHeight;//
  71.  
  72. // frames per second
  73. AVRational rate;
  74. rate.num = 1;
  75. rate.den = 25;
  76. c->time_base= rate;//(AVRational){1,25};
  77. c->gop_size = 10; // emit one intra frame every ten frames
  78. c->max_b_frames=1;
  79. c->thread_count = 1;
  80. c->pix_fmt = PIX_FMT_YUV420P;//PIX_FMT_RGB24;
  81.  
  82. //av_opt_set(c->priv_data, /*"preset"*/"libvpx-1080p.ffpreset", /*"slow"*/NULL, 0);
  83. //打开编码器
  84. if(avcodec_open2(c,pCodecH264,NULL)<0){
  85. printf("avcodec_open2 failed\n");
  86. TRACE("不能打开编码库");
  87. getchar();
  88. }
  89.  
  90. int size = c->width * c->height;
  91.  
  92. yuv_buff = (uint8_t *) malloc((size * 3) / 2); // size for YUV 420
  93.  
  94. //将rgb图像数据填充rgb帧
  95. uint8_t * rgb_buff = new uint8_t[nDataLen];
  96.  
  97. //图象编码 outbuf_size太小会报错,图像清晰度也会差
  98. int outbuf_size = 900000;
  99. uint8_t * outbuf= (uint8_t*)malloc(outbuf_size);
  100. int u_size = 0;
  101. FILE *f=NULL;
  102. char * filename = "myData.h264";
  103. f = fopen(filename, "wb");
  104. if (!f)
  105. {
  106. TRACE( "could not open %s\n", filename);
  107. getchar();
  108. exit(1);
  109. }
  110.  
  111. //初始化SwsContext
  112. SwsContext * scxt = sws_getContext(c->width,c->height,PIX_FMT_BGR24,c->width,c->height,PIX_FMT_YUV420P,SWS_POINT,NULL,NULL,NULL);
  113.  
  114. AVPacket avpkt;
  115.  
  116. //AVFrame *pTFrame=new AVFrame
  117. for (int i=0;i<250;++i)
  118. {
  119.  
  120. //AVFrame *m_pYUVFrame = new AVFrame[1];
  121.  
  122. int index = (i / 25) % 5;
  123. memcpy(rgb_buff,szTxt[index],nDataLen);
  124.  
  125. avpicture_fill((AVPicture*)m_pRGBFrame, (uint8_t*)rgb_buff, PIX_FMT_RGB24, nWidth, nHeight);
  126.  
  127. //将YUV buffer 填充YUV Frame
  128. avpicture_fill((AVPicture*)m_pYUVFrame, (uint8_t*)yuv_buff, PIX_FMT_YUV420P, nWidth, nHeight);
  129.  
  130. // 翻转RGB图像
  131. m_pRGBFrame->data[0] += m_pRGBFrame->linesize[0] * (nHeight - 1);
  132. m_pRGBFrame->linesize[0] *= -1;
  133. m_pRGBFrame->data[1] += m_pRGBFrame->linesize[1] * (nHeight / 2 - 1);
  134. m_pRGBFrame->linesize[1] *= -1;
  135. m_pRGBFrame->data[2] += m_pRGBFrame->linesize[2] * (nHeight / 2 - 1);
  136. m_pRGBFrame->linesize[2] *= -1;
  137.  
  138. //将RGB转化为YUV
  139. sws_scale(scxt,m_pRGBFrame->data,m_pRGBFrame->linesize,0,c->height,m_pYUVFrame->data,m_pYUVFrame->linesize);
  140.  
  141. static int got_packet_ptr = 0;
  142. av_init_packet(&avpkt);
  143. avpkt.data = outbuf;
  144. avpkt.size = outbuf_size;
  145. u_size = avcodec_encode_video2(c, &avpkt, m_pYUVFrame, &got_packet_ptr);
  146. m_pYUVFrame->pts++;
  147. if (u_size == 0)
  148. {
  149. fwrite(avpkt.data, 1, avpkt.size, f);
  150. }
  151. }
  152.  
  153. fclose(f);
  154. delete []m_pRGBFrame;
  155. delete []m_pYUVFrame;
  156. delete []rgb_buff;
  157. free(outbuf);
  158. avcodec_close(c);
  159. av_free(c);
  160.  
  161. }
  162.  
  163. #ifdef __cplusplus
  164. }
  165. #endif

全然依照博客中的代码測试发现会报以下的信息,并且在播放过程中,画面都是模糊的。改动了outbuff_size的大小攻克了这个问题。

 

疑问:为什么要循环250次?有知道麻烦解答下!
  1. for (int i=0;i<250;++i)

将H264视频保存为BMP图片,详细代码例如以下:

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <windows.h>
  5.  
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10. #include <libavcodec/avcodec.h>
  11. #include <libavformat/avformat.h>
  12. #include <libswscale/swscale.h>
  13.  
  14. void SaveAsBMP (AVFrame *pFrameRGB, int width, int height, int index, int bpp)
  15. {
  16. char buf[5] = {0};
  17. BITMAPFILEHEADER bmpheader;
  18. BITMAPINFOHEADER bmpinfo;
  19. FILE *fp;
  20.  
  21. char filename[20] = "";
  22. _itoa (index, buf, 10);
  23. strcat (filename, buf);
  24. strcat (filename, ".bmp");
  25.  
  26. if ( (fp = fopen(filename,"wb+")) == NULL )
  27. {
  28. printf ("open file failed!\n");
  29. return;
  30. }
  31.  
  32. bmpheader.bfType = 0x4d42;
  33. bmpheader.bfReserved1 = 0;
  34. bmpheader.bfReserved2 = 0;
  35. bmpheader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
  36. bmpheader.bfSize = bmpheader.bfOffBits + width*height*bpp/8;
  37.  
  38. bmpinfo.biSize = sizeof(BITMAPINFOHEADER);
  39. bmpinfo.biWidth = width;
  40. bmpinfo.biHeight = height;
  41. bmpinfo.biPlanes = 1;
  42. bmpinfo.biBitCount = bpp;
  43. bmpinfo.biCompression = BI_RGB;
  44. bmpinfo.biSizeImage = (width*bpp+31)/32*4*height;
  45. bmpinfo.biXPelsPerMeter = 100;
  46. bmpinfo.biYPelsPerMeter = 100;
  47. bmpinfo.biClrUsed = 0;
  48. bmpinfo.biClrImportant = 0;
  49.  
  50. fwrite (&bmpheader, sizeof(bmpheader), 1, fp);
  51. fwrite (&bmpinfo, sizeof(bmpinfo), 1, fp);
  52. fwrite (pFrameRGB->data[0], width*height*bpp/8, 1, fp);
  53.  
  54. fclose(fp);
  55. }
  56.  
  57. int main (void)
  58. {
  59. unsigned int i = 0, videoStream = -1;
  60. AVCodecContext *pCodecCtx;
  61. AVFormatContext *pFormatCtx = NULL;
  62. AVCodec *pCodec;
  63. AVFrame *pFrame, *pFrameRGB;
  64. struct SwsContext *pSwsCtx;
  65. const char *filename = "myData.h264";
  66. AVPacket packet;
  67. int frameFinished;
  68. int PictureSize;
  69. uint8_t *buf;
  70.  
  71. av_register_all();
  72.  
  73. if (avformat_open_input(&pFormatCtx, filename, NULL, NULL) != 0 ){
  74. printf ("av open input file failed!\n");
  75. exit (1);
  76. }
  77.  
  78. if ( avformat_find_stream_info(pFormatCtx,NULL) < 0 ){
  79. printf ("av find stream info failed!\n");
  80. exit (1);
  81. }
  82.  
  83. for ( i=0; i<pFormatCtx->nb_streams; i++ ){
  84. if ( pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO ){
  85. videoStream = i;
  86. break;
  87. }
  88. }
  89.  
  90. if (videoStream == -1){
  91. printf ("find video stream failed!\n");
  92. exit (1);
  93. }
  94.  
  95. pCodecCtx = pFormatCtx->streams[videoStream]->codec;
  96.  
  97. pCodec = avcodec_find_decoder (pCodecCtx->codec_id);
  98. if (pCodec == NULL){
  99. printf ("avcode find decoder failed!\n");
  100. exit (1);
  101. }
  102.  
  103. if ( avcodec_open2(pCodecCtx, pCodec,NULL)<0 ){
  104. printf ("avcode open failed!\n");
  105. exit (1);
  106. }
  107.  
  108. pFrame = avcodec_alloc_frame();
  109. pFrameRGB = avcodec_alloc_frame();
  110.  
  111. if ( (pFrame == NULL)||(pFrameRGB == NULL) ){
  112. printf("avcodec alloc frame failed!\n");
  113. exit (1);
  114. }
  115.  
  116. PictureSize = avpicture_get_size (PIX_FMT_BGR24, pCodecCtx->width, pCodecCtx->height);
  117.  
  118. buf = (uint8_t *)av_malloc(PictureSize);
  119.  
  120. if ( buf == NULL ){
  121. printf( "av malloc failed!\n");
  122. exit(1);
  123. }
  124.  
  125. avpicture_fill ( (AVPicture *)pFrameRGB, buf, PIX_FMT_BGR24, pCodecCtx->width, pCodecCtx->height);
  126.  
  127. pSwsCtx = sws_getContext (pCodecCtx->width,
  128. pCodecCtx->height,
  129. pCodecCtx->pix_fmt,
  130. pCodecCtx->width,
  131. pCodecCtx->height,
  132. PIX_FMT_BGR24,
  133. SWS_BICUBIC,
  134. NULL, NULL, NULL);
  135.  
  136. i = 0;
  137.  
  138. while(av_read_frame(pFormatCtx, &packet) >= 0){
  139. if(packet.stream_index == videoStream){
  140. avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
  141.  
  142. if(frameFinished){
  143. //反转图像
  144. pFrame->data[0] += pFrame->linesize[0] * (pCodecCtx->height - 1);
  145. pFrame->linesize[0] *= -1;
  146. pFrame->data[1] += pFrame->linesize[1] * (pCodecCtx->height / 2 - 1);
  147. pFrame->linesize[1] *= -1;
  148. pFrame->data[2] += pFrame->linesize[2] * (pCodecCtx->height / 2 - 1);
  149. pFrame->linesize[2] *= -1;
  150.  
  151. sws_scale (pSwsCtx, pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize);
  152.  
  153. SaveAsBMP (pFrameRGB, pCodecCtx->width, pCodecCtx->height, i++, 24);
  154. }
  155. }
  156. av_free_packet(&packet);
  157. }
  158.  
  159. while(1){
  160. packet.data = NULL;
  161. packet.size = 0;
  162. avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
  163.  
  164. if(frameFinished){
  165. //反转图像
  166. pFrame->data[0] += pFrame->linesize[0] * (pCodecCtx->height - 1);
  167. pFrame->linesize[0] *= -1;
  168. pFrame->data[1] += pFrame->linesize[1] * (pCodecCtx->height / 2 - 1);
  169. pFrame->linesize[1] *= -1;
  170. pFrame->data[2] += pFrame->linesize[2] * (pCodecCtx->height / 2 - 1);
  171. pFrame->linesize[2] *= -1;
  172.  
  173. sws_scale (pSwsCtx, pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize);
  174.  
  175. SaveAsBMP (pFrameRGB, pCodecCtx->width, pCodecCtx->height, i++, 24);
  176. }else{
  177. break;
  178. }
  179.  
  180. av_free_packet(&packet);
  181. }
  182.  
  183. sws_freeContext (pSwsCtx);
  184. av_free (pFrame);
  185. av_free (pFrameRGB);
  186. avcodec_close (pCodecCtx);
  187. avformat_close_input (&pFormatCtx);
  188.  
  189. return 0;
  190. }
  191.  
  192. #ifdef __cplusplus
  193. }
  194. #endif

视频文件保存图片的另外一个方法,看代码

  1. /*File : yuv2pic
  2. *Auth : sjin
  3. *Date : 20141123
  4. *Mail : 413977243@qq.com
  5. */
  6.  
  7. /*
  8. * 參考博客http://blog.csdn.net/leixiaohua1020/article/details/25346147
  9. *本程序实现了YUV420P像素数据编码为JPEG图片。是最简单的FFmpeg编码方面的教程。
  10. *通过学习本样例能够了解FFmpeg的编码流程。
  11. */
  12. #include <libavcodec/avcodec.h>
  13. #include <libavformat/avformat.h>
  14. #include <libswscale/swscale.h>
  15.  
  16. #define INPUT_FILE_NAME "yuv420p.yuv"
  17. #define OUTPUT_FILE_NAME "encode.png"
  18. #define INPUT_FILE_WDITH 176
  19. #define INPUT_FILE_HEIGHT 144
  20.  
  21. int main(int argc, char* argv[])
  22. {
  23. AVFormatContext* pFormatCtx;
  24. AVOutputFormat* fmt;
  25. AVStream* video_st;
  26. AVCodecContext* pCodecCtx;
  27. AVCodec* pCodec;
  28.  
  29. uint8_t* picture_buf;
  30. AVFrame* picture;
  31. int size;
  32.  
  33. FILE *in_file = fopen(INPUT_FILE_NAME, "rb"); //视频YUV源文件
  34. int in_w = INPUT_FILE_WDITH;
  35. int in_h = INPUT_FILE_HEIGHT; //宽高
  36. const char* out_file = OUTPUT_FILE_NAME; //输出文件路径
  37.  
  38. av_register_all();
  39. #if 0
  40. //方法1.组合使用几个函数
  41. pFormatCtx = avformat_alloc_context();
  42. //猜格式。用MJPEG编码
  43. fmt = av_guess_format("mjpeg", NULL, NULL);
  44. pFormatCtx->oformat = fmt;
  45. //注意:输出路径
  46. if (avio_open(&pFormatCtx->pb,out_file, AVIO_FLAG_READ_WRITE) < 0){
  47. printf("输出文件打开失败");
  48. return -1;
  49. }
  50. #else
  51. //方法2.更加自己主动化一些
  52. //分配一个输出(out_file)文件格式的AVFormatContext的上下文句柄
  53. avformat_alloc_output_context2(&pFormatCtx, NULL, NULL, out_file);
  54. fmt = pFormatCtx->oformat;
  55.  
  56. video_st = avformat_new_stream(pFormatCtx,NULL);
  57. if (video_st==NULL){
  58. return -1;
  59. }
  60. #endif
  61. pCodecCtx = video_st->codec;
  62. pCodecCtx->codec_id = fmt->video_codec;
  63. pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
  64. pCodecCtx->pix_fmt = PIX_FMT_YUVJ420P;
  65.  
  66. pCodecCtx->width = in_w;
  67. pCodecCtx->height = in_h;
  68.  
  69. pCodecCtx->time_base.num = 1;
  70. pCodecCtx->time_base.den = 25;
  71. //输出格式信息
  72. av_dump_format(pFormatCtx, 0, out_file, 1);
  73.  
  74. pCodec = avcodec_find_encoder(pCodecCtx->codec_id);
  75. if (!pCodec){
  76. printf("没有找到合适的编码器!");
  77. return -1;
  78. }
  79. if (avcodec_open2(pCodecCtx, pCodec,NULL) < 0){
  80. printf("编码器打开失败!");
  81. return -1;
  82. }
  83.  
  84. //申请解码后保存视频帧的空间,AVFrame结构体
  85. picture = avcodec_alloc_frame();
  86. //即使我们申请的一帧的内存,当转换的时候,我们仍须要内存去保存原始的数据
  87. //利用以下的函数来获得原始数据帧的大小,手动分配内存
  88. size = avpicture_get_size(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
  89. picture_buf = (uint8_t *)av_malloc(size);
  90. if (!picture_buf){
  91. return -1;
  92. }
  93. //设置指定图像的參数,并指着图像数据缓冲区
  94. avpicture_fill((AVPicture *)picture, picture_buf, pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
  95.  
  96. //写文件头
  97. avformat_write_header(pFormatCtx,NULL);
  98.  
  99. AVPacket pkt;
  100. int y_size = pCodecCtx->width * pCodecCtx->height;
  101. av_new_packet(&pkt,y_size*3);
  102. //读入YUV
  103. if (fread(picture_buf, 1, y_size*3/2, in_file) < 0){
  104. printf("文件读取错误");
  105. return -1;
  106. }
  107.  
  108. //翻转图像
  109. picture->data[0] = picture_buf; // 亮度Y
  110. picture->data[1] = picture_buf+ y_size; // U
  111. picture->data[2] = picture_buf+ y_size*5/4; // V
  112. int got_picture=0;
  113. //编码
  114. int ret = avcodec_encode_video2(pCodecCtx, &pkt,picture, &got_picture);
  115. if(ret < 0){
  116. printf("编码错误!\n");
  117. return -1;
  118. }
  119. if (got_picture==1){
  120. pkt.stream_index = video_st->index;
  121. ret = av_write_frame(pFormatCtx, &pkt);
  122. }
  123.  
  124. av_free_packet(&pkt);
  125. //写文件尾
  126. av_write_trailer(pFormatCtx);
  127.  
  128. printf("编码成功!\n");
  129.  
  130. if (video_st){
  131. avcodec_close(video_st->codec);
  132. av_free(picture);
  133. av_free(picture_buf);
  134. }
  135.  
  136. avio_close(pFormatCtx->pb);
  137. avformat_free_context(pFormatCtx);
  138.  
  139. fclose(in_file);
  140.  
  141. return 0;
  142. }

以下是编译的时候,比較好用的Makefile文件

  1. # use pkg-config for getting CFLAGS and LDLIBS
  2. FFMPEG_LIBS= libavdevice \
  3. libavformat \
  4. libavfilter \
  5. libavcodec \
  6. libswresample \
  7. libswscale \
  8. libavutil \
  9.  
  10. CFLAGS += -Wall -O2 -g
  11. CFLAGS := $(shell pkg-config --cflags $(FFMPEG_LIBS)) $(CFLAGS)
  12. LDLIBS := $(shell pkg-config --libs $(FFMPEG_LIBS)) $(LDLIBS)
  13.  
  14. EXAMPLES= yuv2pic
  15.  
  16. OBJS=$(addsuffix .o,$(EXAMPLES))
  17.  
  18. # the following examples make explicit use of the math library
  19. LDLIBS += -lx264 -m32 -pthread -lm -ldl
  20.  
  21. .phony:all clean
  22.  
  23. all: $(OBJS) $(EXAMPLES)
  24.  
  25. clean:
  26. rm $(EXAMPLES) $(OBJS)

使用ffmpeg将BMP图片编码为x264视频文件,将H264视频保存为BMP图片,yuv视频文件保存为图片的代码的更多相关文章

  1. FFmpeg YUV视频序列编码为视频

    上一篇已经写了如何配置好开发环境,这次就先小试牛刀,来个视频的编码.搞视频处理的朋友肯定比较熟悉YUV视频序列,很多测试库提供的视频数据都是YUV视频序列,我们这里就用用YUV视频序列来做视频.关于Y ...

  2. Base64图片编码原理,base64图片工具介绍,图片在线转换Base64

    Base64图片编码原理,base64图片工具介绍,图片在线转换Base64 DataURI 允许在HTML文档中嵌入小文件,可以使用 img 标签或 CSS 嵌入转换后的 Base64 编码,减少  ...

  3. FFmpeg源码结构图 - 编码

    ===================================================== FFmpeg的库函数源码分析文章列表: [架构图] FFmpeg源码结构图 - 解码 FFm ...

  4. Base64图片编码的使用

    一.base64编码介绍 Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一,Base64编码可用于在HTTP环境下传递较长的标识信息.采用Base64编码具有不可读性,即所编码的数据 ...

  5. 【VC++技术杂谈006】截取电脑桌面并将其保存为bmp图片

    本文主要介绍如何截取电脑桌面并将其保存为bmp图片. 1. Bmp图像文件组成 Bmp是Windows操作系统中的标准图像文件格式. Bmp图像文件由四部分组成: (1)位图头文件数据结构,包含Bmp ...

  6. 杂谈SharpDx中的WIC组件——我们需要WIC的图片编码功能么?

    在前文 SharpDX之Direct2D教程II——加载位图文件和保存位图文件 中,发现在VB2010中不能很好的运用SharpDx中的WIC组件进行图片的编码工作.可能是我的设置问题,也可能是Sha ...

  7. android 开发 对图片编码,并生成gif图片

    demo场景: 将2张静态的png格式图片组合生成一个gif图片,间隔500毫秒,关键类:AnimatedGifEncoder 如需要解析gif获取每帧的图片,可参考上一篇博客:<android ...

  8. [转]RGB数据保存为BMP图片

    转自:http://blog.csdn.net/yixianfeng41/article/details/52591585 一.BMP文件由文件头.位图信息头.颜色信息和图形数据四部分组成. 1.BM ...

  9. base64图片编码大小与原图文件大小之间的联系

    base64图片编码大小与原图文件大小之间的联系 有时候我们需要把canvas画布的图画转换成图片输出页面,而用canvas生成的图片就是base64编码的,它是由数字.字母等一大串的字符组成的,但是 ...

随机推荐

  1. CSS块级元素和行内元素

    根据CSS规范的规定,每一个网页元素都有一个display属性,用于确定该元素的类型,每一个元素都有默认的display属性值,比如div元素,它的默认display属性值为“block”,成为“块级 ...

  2. JAVA GUI学习 - JTable表格组件学习_A ***

    public class JTableKnow_A extends JFrame { public JTableKnow_A() { this.setBounds(300, 100, 400, 300 ...

  3. 搞不清FastCgi与PHP-fpm之间是个什么样的关系 - SegmentFault

    搞不清FastCgi与PHP-fpm之间是个什么样的关系 - SegmentFault 搞不清FastCgi与PHP-fpm之间是个什么样的关系 3赞 踩 收藏 我在网上查fastcgi与php-fp ...

  4. Android测试TestSuite的执行方法

    public class StartTest extends InstrumentationTestRunner {         public  TestSuite getAllTests() { ...

  5. SqlServer之like、charindex、patindex(转载)

    SqlServer之like.charindex.patindex   1.环境介绍 测试环境 SQL2005 测试数据 200W条   2.环境准备 2.1建表 CREATE TABLE [dbo] ...

  6. Notepad++中Windows,Unix,Mac三种格式

    Notepad++中Windows,Unix,Mac三种格式之间的转换 http://www.crifan.com/files/doc/docbook/rec_soft_npp/release/htm ...

  7. Node.js学习笔记2(安装和配置Node.js)

            1.安装         windows下安装,在http://nodejs.org下载安装包进行安装即可.         linux下安装,使用yum或者下载源码进行编译.     ...

  8. 一个分组查询 每组前 10 的sql 语句

    USE tmpgo CREATE TABLE Employee( ID int identity(1,1), EmpName varchar(20), EmpSalary varchar(10), E ...

  9. JavaScript时钟实例

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  10. Mac平台编译mupdf-qt的开源项目

    How to compile mupdf-qt Compile on Linux Install tools and thirdparty libraries You should install s ...