EXIF的讀取及修改 |
缺席
|
maped
一般會員 發表:13 回覆:19 積分:6 註冊:2008-10-06 發送簡訊給我 |
|
boss.tw
高階會員 發表:15 回覆:109 積分:194 註冊:2005-05-17 發送簡訊給我 |
請參考
http://www.exiv2.org/#lib or http://delphi.ktop.com.tw/board.php?cid=168&fid=921&tid=30252 Exif規格 http://www.exif.org/specifications.html 方法一: EXIF Tag Parsing Library Source 範例 http://sourceforge.net/project/showfiles.php?group_id=12272&release_id=132198 方法二: 試試這個範例吧! 資料來源:http://www.smalleranimals.com/isource/isourcesample_v2_2.htm Get EXIF data from a JPG EXIF data is stored in the JPGs created by most digital cameras. It contains information about the camera, the environment when the image was taken, the date, time, etc.. [code cpp] UINT32 w,h,d; // get the dimensions - we'll we really don't care about the dims. // we just want to force a JPG marker read and this is the quickest way // to do it. HISSRC hSrc = ISOpenFileSource( pFilename ); ISGetJPGDims( hSrc, &w, &h, &d, NULL); ISCloseSource( hSrc ); // loop over all JPEG_APPx markers int ct=ISGetJPGInputMarkerCount(); for (int i=0; i < ct; i ) { // get a JPG marker from ImgSoruce HGLOBAL hData = NULL; UINT32 len, type; ISGetJPGInputMarker(i, &hData, &len, &type); // only interested in JPEG_APP1 (#225) if (type!=225) { GlobalFree(hData); continue; } else { // start the EXIF parser HGLOBAL hEXIF = ISEXIFInit((BYTE *)hData, len); if (hEXIF!=NULL) { // get string with tag ID #271 (camera model) // look in all subsections (1 | 2 | 4 | 8 = 15) HGLOBAL hStr = NULL; UINT32 uStrLen; ISEXIFGetString(hEXIF, 272, 15, &hStr, &uStrLen); if (hStr!=NULL) { // got it! TRACE("model = %s\n", (char *)hStr); GlobalFree(hStr); } // try the thumbnail HGLOBAL hThumbnail = NULL; UINT32 uTNLen = 0; if (ISEXIFGetThumbnail(hEXIF, &hThumbnail, &uTNLen)==IS_ERR_OK) { // there is a thumbnail. // what format is it? int iFmt = 0; HGLOBAL hStr = NULL; UINT32 uStrLen; ISEXIFGetString(hEXIF, 259, 8, &hStr, &uStrLen); if (hStr!=NULL) { // got it! TRACE("fmt = %s\n", (char *)hStr); iFmt = atoi((char *)hStr); GlobalFree(hStr); } if (iFmt==6) // 6 = JPG. 1 = TIFF, 0 = RGB, but most are JPG { // convet that to RGB HISSRC hSrc = ISOpenMemorySource((BYTE *)hThumbnail, uTNLen); HGLOBAL hImg = ISReadJPG(hSrc, &w, &h, 24); ISCloseSource(hSrc); if (hImg) { // draw it CDC *pDC = GetDC(); ISDrawRGB( pDC->m_hDC, (BYTE *)hImg, w, h, 0, 0, w, h, NULL ); ReleaseDC(pDC); GlobalFree(hImg); } } // clean up GlobalFree(hThumbnail); } // clean up ISEXIFDestroy(hEXIF); } } GlobalFree(hData); } [/code] |
maped
一般會員 發表:13 回覆:19 積分:6 註冊:2008-10-06 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |