读取JPG图片的Exif属性(二) - C代码实现_exif解析 c语言-程序员宅基地

技术标签: jpg  Exif  C++  图片  图像知识  GPS  

读区Exif属性简介

        读取Exif基本上就是在懂得Exif的格式的基础上,详细见上文: 

读取JPG图片的Exif属性 - Exif信息简介

然后就是对图片的数据进行字节分析了。这个分析也是非常重要的,就是一个一个字节来分析图片的Exif属性,一般这段字节就是图片的开始部分。可以使用 工具将JPG图片按照16进制的格式打开,然后在对着图片来分析。

        由于国内关于此部分的讲述非常少,我在国外的一个网站上找到一个简单的读取Exif属性的实例,下面就是关于这个demo自己做的一些修改和理解。

如下是一个实际图片的16进制数据:
FF D8 FF E0 00 10 4A 46 49 46 00 01 02 01 00 60
00 60   00 00 FF E1 08 32 45 78 69 66 00 00 49 49

  DecodeExif 函数主要是获取到Eixf属性在图片数据中入口地址:

第一次执行 DecodeExif 中的for(;;)读取的是section FF E0 M_JFIF
 FF D8       SOI
 FF E0       APP0
 00 10      APP0 LENGTH = 16

FF D8 FF E0  00 10 4A 46 49 46 00 01 02 01 00 60
00 60   00 00 FF E1 08 32 45 78 69 66 00 00 49 49
蓝色部分就是读取的长度16个字节。

第二次次执行 DecodeExif 中的for(;;)读取的是section FF E0 M_JFIF

FF D8 FF E0  00 10 4A 46 49 46 00 01 02 01 00 60
00 60   00 00  FF E1  08 32  45 78 69 66 00 00  49 49

FF E1      APP1
  08 32      APP0 LENGTH = 08 32 = 2098
45 78 69 66   "Exif" 字符 
也就是代码: if ( memcmp ( Data + 2 , "Exif" , 4 ) == 0 )所定义那样,获取四个字符,
从FF E1开始 长度为2098 个字节。
m_exifinfo -> IsExif = process_EXIF (( unsigned char *) Data + 2 , itemlen );
从这个函数开始,分析Exif各种属性,也就是 获取到Eixf属性在图片数据中入口地址以及Exif所占的长度
   
   
    
  1. bool Cexif::DecodeExif(FILE * hFile)
  2. {
  3. int a;
  4. int HaveCom = 0;
  5. a = fgetc(hFile);
  6. if (a != 0xff || fgetc(hFile) != M_SOI){
  7. return 0;
  8. }
  9. for(;;){
  10. int itemlen;
  11. int marker = 0;
  12. int ll,lh, got;
  13. unsigned char * Data;
  14. if (SectionsRead >= MAX_SECTIONS){
  15. strcpy(m_szLastError,"Too many sections in jpg file");
  16. return 0;
  17. }
  18. for (a=0;a<7;a++){
  19. marker = fgetc(hFile);
  20. if (marker != 0xff) break;
  21. if (a >= 6){
  22. printf("too many padding unsigned chars\n");
  23. return 0;
  24. }
  25. }
  26. if (marker == 0xff){
  27. // 0xff is legal padding, but if we get that many, something's wrong.
  28. strcpy(m_szLastError,"too many padding unsigned chars!");
  29. return 0;
  30. }
  31. Sections[SectionsRead].Type = marker;
  32. // Read the length of the section.
  33. lh = fgetc(hFile);
  34. ll = fgetc(hFile);
  35. itemlen = (lh << 8) | ll;
  36. if (itemlen < 2){
  37. strcpy(m_szLastError,"invalid marker");
  38. return 0;
  39. }
  40. Sections[SectionsRead].Size = itemlen;
  41. Data = (unsigned char *)malloc(itemlen);
  42. if (Data == NULL){
  43. strcpy(m_szLastError,"Could not allocate memory");
  44. return 0;
  45. }
  46. Sections[SectionsRead].Data = Data;
  47. // Store first two pre-read unsigned chars.
  48. Data[0] = (unsigned char)lh;
  49. Data[1] = (unsigned char)ll;
  50. got = fread(Data+2, 1, itemlen-2,hFile); // Read the whole section.
  51. if (got != itemlen-2){
  52. strcpy(m_szLastError,"Premature end of file?");
  53. return 0;
  54. }
  55. SectionsRead += 1;
  56. switch(marker){
  57. case M_SOS: // stop before hitting compressed data
  58. // If reading entire image is requested, read the rest of the data.
  59. /*if (ReadMode & READ_IMAGE){
  60. int cp, ep, size;
  61. // Determine how much file is left.
  62. cp = ftell(infile);
  63. fseek(infile, 0, SEEK_END);
  64. ep = ftell(infile);
  65. fseek(infile, cp, SEEK_SET);
  66. size = ep-cp;
  67. Data = (uchar *)malloc(size);
  68. if (Data == NULL){
  69. strcpy(m_szLastError,"could not allocate data for entire image");
  70. return 0;
  71. }
  72. got = fread(Data, 1, size, infile);
  73. if (got != size){
  74. strcpy(m_szLastError,"could not read the rest of the image");
  75. return 0;
  76. }
  77. Sections[SectionsRead].Data = Data;
  78. Sections[SectionsRead].Size = size;
  79. Sections[SectionsRead].Type = PSEUDO_IMAGE_MARKER;
  80. SectionsRead ++;
  81. HaveAll = 1;
  82. }*/
  83. return 1;
  84. case M_EOI: // in case it's a tables-only JPEG stream
  85. printf("No image in jpeg!\n");
  86. return 0;
  87. case M_COM: // Comment section
  88. if (HaveCom){
  89. // Discard this section.
  90. free(Sections[--SectionsRead].Data);
  91. Sections[SectionsRead].Data=0;
  92. }else{
  93. process_COM(Data, itemlen);
  94. HaveCom = 1;
  95. }
  96. break;
  97. case M_JFIF:
  98. // Regular jpegs always have this tag, exif images have the exif
  99. // marker instead, althogh ACDsee will write images with both markers.
  100. // this program will re-create this marker on absence of exif marker.
  101. // hence no need to keep the copy from the file.
  102. free(Sections[--SectionsRead].Data);
  103. Sections[SectionsRead].Data=0;
  104. break;
  105. case M_EXIF:
  106. // Seen files from some 'U-lead' software with Vivitar scanner
  107. // that uses marker 31 for non exif stuff. Thus make sure
  108. // it says 'Exif' in the section before treating it as exif.
  109. if (memcmp(Data+2, "Exif", 4) == 0){
  110. m_exifinfo->IsExif = process_EXIF((unsigned char *)Data+2, itemlen);
  111. }else{
  112. // Discard this section.
  113. free(Sections[--SectionsRead].Data);
  114. Sections[SectionsRead].Data=0;
  115. }
  116. break;
  117. case M_SOF0:
  118. case M_SOF1:
  119. case M_SOF2:
  120. case M_SOF3:
  121. case M_SOF5:
  122. case M_SOF6:
  123. case M_SOF7:
  124. case M_SOF9:
  125. case M_SOF10:
  126. case M_SOF11:
  127. case M_SOF13:
  128. case M_SOF14:
  129. case M_SOF15:
  130. process_SOFn(Data, marker);
  131. break;
  132. default:
  133. // Skip any other sections.
  134. //if (ShowTags) printf("Jpeg section marker 0x%02x size %d\n",marker, itemlen);
  135. break;
  136. }
  137. }
  138. return 1;
  139. }

粗略分析Exif属性

FF D8 FF E0  00 10 4A 46 49 46 00 01 02 01 00 60
00 60   00 00   FF E1   08 32  45 78 69 66  00 00  49 49
2A 00  08 00 00 00   0B 00 0F 01 02 00 05 00 00 00
A2 00 00 00 10 01   02 00 20 00 00 00 A8 00 00 00
process_EXIF 
主要是对Exif属性做一个前期的处理,为了进一步详细的分析做处理。
由于EXIF是一种可交换的文件格式,所以可以用在Intel系列和Motorola系列的CPU上(至于两者CPU的区别,大家可以到网上找找,这里不做说明)。在文件中有一个标志,如果是“MM”表示Motorola的CPU,否则为“II”表示Intel的CPU。
  49 49   表示的是小端,小端的时候要格外注意其取字符的时候是从后往前取,才能获得正确的数据。
  4D 4D   表示的是大端
2A 00  表示的是 检查下面 2 个字节是否是 0x2A00
08 00 00 00  判断下面的 0th IFD Offset 是否是 0x08000000

    
    
     
  1. /*--------------------------------------------------------------------------
  2. Process a EXIF marker
  3. Describes all the drivel that most digital cameras include...
  4. --------------------------------------------------------------------------*/
  5. bool Cexif::process_EXIF(unsigned char * CharBuf, unsigned int length)
  6. {
  7. m_exifinfo->FlashUsed = 0;
  8. /* If it's from a digicam, and it used flash, it says so. */
  9. m_exifinfo->Comments[0] = '\0'; /* Initial value - null string */
  10. ExifImageWidth = 0;
  11. { /* Check the EXIF header component */
  12. static const unsigned char ExifHeader[] = "Exif\0\0";
  13. if (memcmp(CharBuf+0, ExifHeader,6)){
  14. strcpy(m_szLastError,"Incorrect Exif header");
  15. return 0;
  16. }
  17. }
  18. if (memcmp(CharBuf+6,"II",2) == 0){
  19. MotorolaOrder = 0;
  20. }else{
  21. if (memcmp(CharBuf+6,"MM",2) == 0){
  22. MotorolaOrder = 1;
  23. }else{
  24. strcpy(m_szLastError,"Invalid Exif alignment marker.");
  25. return 0;
  26. }
  27. }
  28. /* Check the next two values for correctness. */
  29. if (Get16u(CharBuf+8) != 0x2a){
  30. strcpy(m_szLastError,"Invalid Exif start (1)");
  31. return 0;
  32. }
  33. int FirstOffset = Get32u(CharBuf+10);
  34. if (FirstOffset < 8 || FirstOffset > 16){
  35. // I used to ensure this was set to 8 (website I used indicated its 8)
  36. // but PENTAX Optio 230 has it set differently, and uses it as offset. (Sept 11 2002)
  37. strcpy(m_szLastError,"Suspicious offset of first IFD value");
  38. return 0;
  39. }
  40. unsigned char * LastExifRefd = CharBuf;
  41. /* First directory starts 16 unsigned chars in. Offsets start at 8 unsigned chars in. */
  42. if (!ProcessExifDir(CharBuf+14, CharBuf+6, length-6, m_exifinfo, &LastExifRefd))
  43. return 0;
  44. /* This is how far the interesting (non thumbnail) part of the exif went. */
  45. // int ExifSettingsLength = LastExifRefd - CharBuf;
  46. /* Compute the CCD width, in milimeters. */
  47. if (m_exifinfo->FocalplaneXRes != 0){
  48. m_exifinfo->CCDWidth = (float)(ExifImageWidth * m_exifinfo->FocalplaneUnits / m_exifinfo->FocalplaneXRes);
  49. }
  50. return 1;
  51. }

详细分析Exif属性

FF D8 FF E0  00 10 4A 46 49 46 00 01 02 01 00 60
00 60   00 00   FF E1   08 32  45 78 69 66  00 00  49 49
2A 00  08 00 00 00    0B 00 0F 01 02 00 05 00 00 00
A2 00 00 00 10 01   02 00 20 00 00 00 A8 00 00 00

0B 00   Tag总共的数量,12个, 00 0B, 所以下面就主要围绕这个12个tag来寻找其属性
一个tag的格式就是:
Tag 类型名
Format: 格式,tag TYPE
count:    最多的字符个数为
offset: 偏移量,但是这里的偏移量要记得加上从(II    49 49 )+1D

按照第一个实例:

                                            0F 01  02 00  05 00 00 00
A2 00 00 00 10 01   02 00 20 00 00 00 A8 00 00 00

Tag   0F 01      TAG Image input equipment manuf 
Format: 格式,  02 00, 格式为2
count:     05 00 00 00  为5
offset: 偏移量, A2 00 00 00   +1D    ,需要移动到 C0
* LastExifRefdP = ValuePtr + BytesCount ; 获取获得数据的 46 4C 49 52  

一次类推获得相关的tag数据,都是这样获得。关于GPS信息的话,且听下回分解。
    
    
     
  1. /*--------------------------------------------------------------------------
  2. Process one of the nested EXIF directories.
  3. --------------------------------------------------------------------------*/
  4. bool Cexif::ProcessExifDir(unsigned char * DirStart, unsigned char * OffsetBase, unsigned ExifLength,
  5. EXIFINFO * const m_exifinfo, unsigned char ** const LastExifRefdP )
  6. {
  7. int de;
  8. int a;
  9. int NumDirEntries;
  10. unsigned ThumbnailOffset = 0;
  11. unsigned ThumbnailSize = 0;
  12. NumDirEntries = Get16u(DirStart);
  13. if ((DirStart+2+NumDirEntries*12) > (OffsetBase+ExifLength)){
  14. strcpy(m_szLastError,"Illegally sized directory");
  15. return 0;
  16. }
  17. for (de=0;de<NumDirEntries;de++){
  18. int Tag, Format, Components;
  19. unsigned char * ValuePtr;
  20. /* This actually can point to a variety of things; it must be
  21. cast to other types when used. But we use it as a unsigned char-by-unsigned char
  22. cursor, so we declare it as a pointer to a generic unsigned char here.
  23. */
  24. int BytesCount;
  25. unsigned char * DirEntry;
  26. DirEntry = DirStart+2+12*de;
  27. Tag = Get16u(DirEntry);
  28. Format = Get16u(DirEntry+2);
  29. Components = Get32u(DirEntry+4);
  30. if ((Format-1) >= NUM_FORMATS) {
  31. /* (-1) catches illegal zero case as unsigned underflows to positive large */
  32. strcpy(m_szLastError,"Illegal format code in EXIF dir");
  33. return 0;
  34. }
  35. BytesCount = Components * BytesPerFormat[Format];
  36. if (BytesCount > 4){
  37. unsigned OffsetVal;
  38. OffsetVal = Get32u(DirEntry+8);
  39. /* If its bigger than 4 unsigned chars, the dir entry contains an offset.*/
  40. if (OffsetVal+BytesCount > ExifLength){
  41. /* Bogus pointer offset and / or unsigned charcount value */
  42. strcpy(m_szLastError,"Illegal pointer offset value in EXIF.");
  43. return 0;
  44. }
  45. ValuePtr = OffsetBase+OffsetVal;
  46. }else{
  47. /* 4 unsigned chars or less and value is in the dir entry itself */
  48. ValuePtr = DirEntry+8;
  49. }
  50. if (*LastExifRefdP < ValuePtr+BytesCount){
  51. /* Keep track of last unsigned char in the exif header that was
  52. actually referenced. That way, we know where the
  53. discardable thumbnail data begins.
  54. */
  55. *LastExifRefdP = ValuePtr+BytesCount;
  56. }
  57. /* Extract useful components of tag */
  58. switch(Tag){
  59. case TAG_MAKE:
  60. strncpy(m_exifinfo->CameraMake, (char*)ValuePtr, 31);
  61. break;
  62. case TAG_MODEL:
  63. strncpy(m_exifinfo->CameraModel, (char*)ValuePtr, 39);
  64. break;
  65. case TAG_EXIF_VERSION:
  66. strncpy(m_exifinfo->Version,(char*)ValuePtr, 4);
  67. break;
  68. case TAG_DATETIME_ORIGINAL:
  69. strncpy(m_exifinfo->DateTime, (char*)ValuePtr, 19);
  70. break;
  71. case TAG_USERCOMMENT:
  72. // Olympus has this padded with trailing spaces. Remove these first.
  73. for (a=BytesCount;;){
  74. a--;
  75. if (((char*)ValuePtr)[a] == ' '){
  76. ((char*)ValuePtr)[a] = '\0';
  77. }else{
  78. break;
  79. }
  80. if (a == 0) break;
  81. }
  82. /* Copy the comment */
  83. if (memcmp(ValuePtr, "ASCII",5) == 0){
  84. for (a=5;a<10;a++){
  85. char c;
  86. c = ((char*)ValuePtr)[a];
  87. if (c != '\0' && c != ' '){
  88. strncpy(m_exifinfo->Comments, (char*)ValuePtr+a, 199);
  89. break;
  90. }
  91. }
  92. }else{
  93. strncpy(m_exifinfo->Comments, (char*)ValuePtr, 199);
  94. }
  95. break;
  96. case TAG_FNUMBER:
  97. /* Simplest way of expressing aperture, so I trust it the most.
  98. (overwrite previously computd value if there is one)
  99. */
  100. m_exifinfo->ApertureFNumber = (float)ConvertAnyFormat(ValuePtr, Format);
  101. break;
  102. case TAG_APERTURE:
  103. case TAG_MAXAPERTURE:
  104. /* More relevant info always comes earlier, so only
  105. use this field if we don't have appropriate aperture
  106. information yet.
  107. */
  108. if (m_exifinfo->ApertureFNumber == 0){
  109. m_exifinfo->ApertureFNumber = (float)exp(ConvertAnyFormat(ValuePtr, Format)*log(2)*0.5);
  110. }
  111. break;
  112. case TAG_BRIGHTNESS:
  113. m_exifinfo->Brightness = (float)ConvertAnyFormat(ValuePtr, Format);
  114. break;
  115. case TAG_FOCALLENGTH:
  116. /* Nice digital cameras actually save the focal length
  117. as a function of how farthey are zoomed in.
  118. */
  119. m_exifinfo->FocalLength = (float)ConvertAnyFormat(ValuePtr, Format);
  120. break;
  121. case TAG_SUBJECT_DISTANCE:
  122. /* Inidcates the distacne the autofocus camera is focused to.
  123. Tends to be less accurate as distance increases.
  124. */
  125. m_exifinfo->Distance = (float)ConvertAnyFormat(ValuePtr, Format);
  126. break;
  127. case TAG_EXPOSURETIME:
  128. /* Simplest way of expressing exposure time, so I
  129. trust it most. (overwrite previously computd value
  130. if there is one)
  131. */
  132. m_exifinfo->ExposureTime =
  133. (float)ConvertAnyFormat(ValuePtr, Format);
  134. break;
  135. case TAG_SHUTTERSPEED:
  136. /* More complicated way of expressing exposure time,
  137. so only use this value if we don't already have it
  138. from somewhere else.
  139. */
  140. if (m_exifinfo->ExposureTime == 0){
  141. m_exifinfo->ExposureTime = (float)
  142. (1/exp(ConvertAnyFormat(ValuePtr, Format)*log(2)));
  143. }
  144. break;
  145. case TAG_FLASH:
  146. if ((int)ConvertAnyFormat(ValuePtr, Format) & 7){
  147. m_exifinfo->FlashUsed = 1;
  148. }else{
  149. m_exifinfo->FlashUsed = 0;
  150. }
  151. break;
  152. case TAG_ORIENTATION:
  153. m_exifinfo->Orientation = (int)ConvertAnyFormat(ValuePtr, Format);
  154. if (m_exifinfo->Orientation < 1 || m_exifinfo->Orientation > 8){
  155. strcpy(m_szLastError,"Undefined rotation value");
  156. m_exifinfo->Orientation = 0;
  157. }
  158. break;
  159. case TAG_EXIF_IMAGELENGTH:
  160. case TAG_EXIF_IMAGEWIDTH:
  161. /* Use largest of height and width to deal with images
  162. that have been rotated to portrait format.
  163. */
  164. a = (int)ConvertAnyFormat(ValuePtr, Format);
  165. if (ExifImageWidth < a) ExifImageWidth = a;
  166. break;
  167. case TAG_FOCALPLANEXRES:
  168. m_exifinfo->FocalplaneXRes = (float)ConvertAnyFormat(ValuePtr, Format);
  169. break;
  170. case TAG_FOCALPLANEYRES:
  171. m_exifinfo->FocalplaneYRes = (float)ConvertAnyFormat(ValuePtr, Format);
  172. break;
  173. case TAG_RESOLUTIONUNIT:
  174. switch((int)ConvertAnyFormat(ValuePtr, Format)){
  175. case 1: m_exifinfo->ResolutionUnit = 1.0f; break; /* 1 inch */
  176. case 2: m_exifinfo->ResolutionUnit = 1.0f; break;
  177. case 3: m_exifinfo->ResolutionUnit = 0.3937007874f; break; /* 1 centimeter*/
  178. case 4: m_exifinfo->ResolutionUnit = 0.03937007874f; break; /* 1 millimeter*/
  179. case 5: m_exifinfo->ResolutionUnit = 0.00003937007874f; /* 1 micrometer*/
  180. }
  181. break;
  182. case TAG_FOCALPLANEUNITS:
  183. switch((int)ConvertAnyFormat(ValuePtr, Format)){
  184. case 1: m_exifinfo->FocalplaneUnits = 1.0f; break; /* 1 inch */
  185. case 2: m_exifinfo->FocalplaneUnits = 1.0f; break;
  186. case 3: m_exifinfo->FocalplaneUnits = 0.3937007874f; break; /* 1 centimeter*/
  187. case 4: m_exifinfo->FocalplaneUnits = 0.03937007874f; break; /* 1 millimeter*/
  188. case 5: m_exifinfo->FocalplaneUnits = 0.00003937007874f; /* 1 micrometer*/
  189. }
  190. break;
  191. // Remaining cases contributed by: Volker C. Schoech <schoech(at)gmx(dot)de>
  192. case TAG_EXPOSURE_BIAS:
  193. m_exifinfo->ExposureBias = (float) ConvertAnyFormat(ValuePtr, Format);
  194. break;
  195. case TAG_WHITEBALANCE:
  196. m_exifinfo->Whitebalance = (int)ConvertAnyFormat(ValuePtr, Format);
  197. break;
  198. case TAG_METERING_MODE:
  199. m_exifinfo->MeteringMode = (int)ConvertAnyFormat(ValuePtr, Format);
  200. break;
  201. case TAG_EXPOSURE_PROGRAM:
  202. m_exifinfo->ExposureProgram = (int)ConvertAnyFormat(ValuePtr, Format);
  203. break;
  204. case TAG_ISO_EQUIVALENT:
  205. m_exifinfo->ISOequivalent = (int)ConvertAnyFormat(ValuePtr, Format);
  206. if ( m_exifinfo->ISOequivalent < 50 ) m_exifinfo->ISOequivalent *= 200;
  207. break;
  208. case TAG_COMPRESSION_LEVEL:
  209. m_exifinfo->CompressionLevel = (int)ConvertAnyFormat(ValuePtr, Format);
  210. break;
  211. case TAG_XRESOLUTION:
  212. m_exifinfo->Xresolution = (float)ConvertAnyFormat(ValuePtr, Format);
  213. break;
  214. case TAG_YRESOLUTION:
  215. m_exifinfo->Yresolution = (float)ConvertAnyFormat(ValuePtr, Format);
  216. break;
  217. case TAG_THUMBNAIL_OFFSET:
  218. ThumbnailOffset = (unsigned)ConvertAnyFormat(ValuePtr, Format);
  219. break;
  220. case TAG_THUMBNAIL_LENGTH:
  221. ThumbnailSize = (unsigned)ConvertAnyFormat(ValuePtr, Format);
  222. break;
  223. }
  224. if (Tag == TAG_EXIF_OFFSET || Tag == TAG_INTEROP_OFFSET){
  225. unsigned char * SubdirStart;
  226. SubdirStart = OffsetBase + Get32u(ValuePtr);
  227. if (SubdirStart < OffsetBase ||
  228. SubdirStart > OffsetBase+ExifLength){
  229. strcpy(m_szLastError,"Illegal subdirectory link");
  230. return 0;
  231. }
  232. ProcessExifDir(SubdirStart, OffsetBase, ExifLength, m_exifinfo, LastExifRefdP);
  233. continue;
  234. }
  235. }
  236. {
  237. /* In addition to linking to subdirectories via exif tags,
  238. there's also a potential link to another directory at the end
  239. of each directory. This has got to be the result of a
  240. committee!
  241. */
  242. unsigned char * SubdirStart;
  243. unsigned Offset;
  244. Offset = Get16u(DirStart+2+12*NumDirEntries);
  245. if (Offset){
  246. SubdirStart = OffsetBase + Offset;
  247. if (SubdirStart < OffsetBase
  248. || SubdirStart > OffsetBase+ExifLength){
  249. strcpy(m_szLastError,"Illegal subdirectory link");
  250. return 0;
  251. }
  252. ProcessExifDir(SubdirStart, OffsetBase, ExifLength, m_exifinfo, LastExifRefdP);
  253. }
  254. }
  255. if (ThumbnailSize && ThumbnailOffset){
  256. if (ThumbnailSize + ThumbnailOffset <= ExifLength){
  257. /* The thumbnail pointer appears to be valid. Store it. */
  258. m_exifinfo->ThumbnailPointer = OffsetBase + ThumbnailOffset;
  259. m_exifinfo->ThumbnailSize = ThumbnailSize;
  260. }
  261. }
  262. return 1;
  263. }

Demo最终实现的结果


参考文档






版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/fioletfly/article/details/54094940

智能推荐

Docker 快速上手学习入门教程_docker菜鸟教程-程序员宅基地

文章浏览阅读2.5w次,点赞6次,收藏50次。官方解释是,docker 容器是机器上的沙盒进程,它与主机上的所有其他进程隔离。所以容器只是操作系统中被隔离开来的一个进程,所谓的容器化,其实也只是对操作系统进行欺骗的一种语法糖。_docker菜鸟教程

电脑技巧:Windows系统原版纯净软件必备的两个网站_msdn我告诉你-程序员宅基地

文章浏览阅读5.7k次,点赞3次,收藏14次。该如何避免的,今天小编给大家推荐两个下载Windows系统官方软件的资源网站,可以杜绝软件捆绑等行为。该站提供了丰富的Windows官方技术资源,比较重要的有MSDN技术资源文档库、官方工具和资源、应用程序、开发人员工具(Visual Studio 、SQLServer等等)、系统镜像、设计人员工具等。总的来说,这两个都是非常优秀的Windows系统镜像资源站,提供了丰富的Windows系统镜像资源,并且保证了资源的纯净和安全性,有需要的朋友可以去了解一下。这个非常实用的资源网站的创建者是国内的一个网友。_msdn我告诉你

vue2封装对话框el-dialog组件_<el-dialog 封装成组件 vue2-程序员宅基地

文章浏览阅读1.2k次。vue2封装对话框el-dialog组件_

MFC 文本框换行_c++ mfc同一框内输入二行怎么换行-程序员宅基地

文章浏览阅读4.7k次,点赞5次,收藏6次。MFC 文本框换行 标签: it mfc 文本框1.将Multiline属性设置为True2.换行是使用"\r\n" (宽字符串为L"\r\n")3.如果需要编辑并且按Enter键换行,还要将 Want Return 设置为 True4.如果需要垂直滚动条的话将Vertical Scroll属性设置为True,需要水平滚动条的话将Horizontal Scroll属性设_c++ mfc同一框内输入二行怎么换行

redis-desktop-manager无法连接redis-server的解决方法_redis-server doesn't support auth command or ismis-程序员宅基地

文章浏览阅读832次。检查Linux是否是否开启所需端口,默认为6379,若未打开,将其开启:以root用户执行iptables -I INPUT -p tcp --dport 6379 -j ACCEPT如果还是未能解决,修改redis.conf,修改主机地址:bind 192.168.85.**;然后使用该配置文件,重新启动Redis服务./redis-server redis.conf..._redis-server doesn't support auth command or ismisconfigured. try

实验四 数据选择器及其应用-程序员宅基地

文章浏览阅读4.9k次。济大数电实验报告_数据选择器及其应用

随便推点

灰色预测模型matlab_MATLAB实战|基于灰色预测河南省社会消费品零售总额预测-程序员宅基地

文章浏览阅读236次。1研究内容消费在生产中占据十分重要的地位,是生产的最终目的和动力,是保持省内经济稳定快速发展的核心要素。预测河南省社会消费品零售总额,是进行宏观经济调控和消费体制改变创新的基础,是河南省内人民对美好的全面和谐社会的追求的要求,保持河南省经济稳定和可持续发展具有重要意义。本文建立灰色预测模型,利用MATLAB软件,预测出2019年~2023年河南省社会消费品零售总额预测值分别为21881...._灰色预测模型用什么软件

log4qt-程序员宅基地

文章浏览阅读1.2k次。12.4-在Qt中使用Log4Qt输出Log文件,看这一篇就足够了一、为啥要使用第三方Log库,而不用平台自带的Log库二、Log4j系列库的功能介绍与基本概念三、Log4Qt库的基本介绍四、将Log4qt组装成为一个单独模块五、使用配置文件的方式配置Log4Qt六、使用代码的方式配置Log4Qt七、在Qt工程中引入Log4Qt库模块的方法八、获取示例中的源代码一、为啥要使用第三方Log库,而不用平台自带的Log库首先要说明的是,在平时开发和调试中开发平台自带的“打印输出”已经足够了。但_log4qt

100种思维模型之全局观思维模型-67_计算机中对于全局观的-程序员宅基地

文章浏览阅读786次。全局观思维模型,一个教我们由点到线,由线到面,再由面到体,不断的放大格局去思考问题的思维模型。_计算机中对于全局观的

线程间控制之CountDownLatch和CyclicBarrier使用介绍_countdownluach于cyclicbarrier的用法-程序员宅基地

文章浏览阅读330次。一、CountDownLatch介绍CountDownLatch采用减法计算;是一个同步辅助工具类和CyclicBarrier类功能类似,允许一个或多个线程等待,直到在其他线程中执行的一组操作完成。二、CountDownLatch俩种应用场景: 场景一:所有线程在等待开始信号(startSignal.await()),主流程发出开始信号通知,既执行startSignal.countDown()方法后;所有线程才开始执行;每个线程执行完发出做完信号,既执行do..._countdownluach于cyclicbarrier的用法

自动化监控系统Prometheus&Grafana_-自动化监控系统prometheus&grafana实战-程序员宅基地

文章浏览阅读508次。Prometheus 算是一个全能型选手,原生支持容器监控,当然监控传统应用也不是吃干饭的,所以就是容器和非容器他都支持,所有的监控系统都具备这个流程,_-自动化监控系统prometheus&grafana实战

React 组件封装之 Search 搜索_react search-程序员宅基地

文章浏览阅读4.7k次。输入关键字,可以通过键盘的搜索按钮完成搜索功能。_react search