Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (5)
Tags (1)
master
FixForKlayGE
FixGCC
FixArm
FixC++17
3.18.0
master
Branches (5)
Tags (1)
master
FixForKlayGE
FixGCC
FixArm
FixC++17
3.18.0
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (5)
Tags (1)
master
FixForKlayGE
FixGCC
FixArm
FixC++17
3.18.0
FreeImage
/
TestAPI
/
testHeaderOnly.cpp
FreeImage
/
TestAPI
/
testHeaderOnly.cpp
testHeaderOnly.cpp 6.99 KB
Copy Edit Raw Blame History
drolon authored 2017年11月16日 06:32 +08:00 . CVS2SVN migration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
// ==========================================================
// FreeImage 3 Test Script
//
// Design and implementation by
// - Herv Drolon (drolon@infonie.fr)
//
// This file is part of FreeImage 3
//
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
// THIS DISCLAIMER.
//
// Use at your own risk!
// ==========================================================
#include "TestSuite.h"
// Local test functions
// ----------------------------------------------------------
void testSupportsNoPixels() {
for (int i = 0; i < FreeImage_GetFIFCount(); i++) {
FREE_IMAGE_FORMAT fmt = (FREE_IMAGE_FORMAT)i;
if (!FreeImage_FIFSupportsNoPixels(fmt)) {
// 'header only' loading mode is not supported
continue;
}
printf("testSupportsNoPixels (%s) ...\n", FreeImage_GetFormatFromFIF(fmt));
}
}
/**
Test header only bitmap allocation
*/
BOOL testHeader(const char *lpszPathName) {
int flags = FIF_LOAD_NOPIXELS;
FIBITMAP *dib1 = NULL, *dib2 = NULL;
try {
FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(lpszPathName);
dib1 = FreeImage_Load(fif, lpszPathName, flags);
if(!dib1) throw(1);
dib2 = FreeImage_Clone(dib1);
if(!dib2) throw(1);
FreeImage_Unload(dib1);
FreeImage_Unload(dib2);
return TRUE;
}
catch(int) {
if(dib1) FreeImage_Unload(dib1);
if(dib2) FreeImage_Unload(dib2);
}
return FALSE;
}
/**
Parse metadata attached to a dib
*/
static void ParseMetadata(FIBITMAP *dib, FREE_IMAGE_MDMODEL model) {
FITAG *tag = NULL;
FIMETADATA *mdhandle = NULL;
mdhandle = FreeImage_FindFirstMetadata(model, dib, &tag);
if(mdhandle) {
do {
// get the tag key
const char *key = FreeImage_GetTagKey(tag);
// convert the tag value to a string
const char *value = FreeImage_TagToString(model, tag);
// print the tag
// note that most tags do not have a description,
// especially when the metadata specifications are not available
if(FreeImage_GetTagDescription(tag)) {
//cout << FreeImage_GetTagKey(tag) << "=" << value << " - " << FreeImage_GetTagDescription(tag) << "\n";
} else {
//cout << FreeImage_GetTagKey(tag) << "=" << value << " - " << "\n";
}
} while(FreeImage_FindNextMetadata(mdhandle, &tag));
}
FreeImage_FindCloseMetadata(mdhandle);
}
/**
Load the header of a bitmap (without pixel data)
*/
BOOL testHeaderData(const char *lpszPathName) {
int flags = FIF_LOAD_NOPIXELS;
FIBITMAP *dib = NULL;
try {
// load a file using the FIF_LOAD_NOPIXELS flag
FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(lpszPathName);
assert(FreeImage_FIFSupportsNoPixels(fif) == TRUE);
dib = FreeImage_Load(fif, lpszPathName, flags);
if(!dib) throw(1);
// check that dib does not contains pixels
BOOL bHasPixel = FreeImage_HasPixels(dib);
assert(bHasPixel == FALSE);
// use accessors
FREE_IMAGE_TYPE type = FreeImage_GetImageType(dib);
unsigned width = FreeImage_GetWidth(dib);
unsigned height = FreeImage_GetHeight(dib);
unsigned bpp = FreeImage_GetBPP(dib);
// parse some metadata (see e.g. FreeImage_FindFirstMetadata)
ParseMetadata(dib, FIMD_COMMENTS);
ParseMetadata(dib, FIMD_EXIF_MAIN);
ParseMetadata(dib, FIMD_EXIF_EXIF);
ParseMetadata(dib, FIMD_EXIF_GPS);
ParseMetadata(dib, FIMD_EXIF_MAKERNOTE);
ParseMetadata(dib, FIMD_IPTC);
ParseMetadata(dib, FIMD_XMP);
// you cannot access pixels
BYTE *bits = FreeImage_GetBits(dib);
assert(bits == NULL);
FreeImage_Unload(dib);
return TRUE;
}
catch(int) {
if(dib) FreeImage_Unload(dib);
}
return FALSE;
}
/**
Test loading and saving of Exif raw data
*/
static BOOL
testExifRawFile(const char *lpszPathName, int load_flags, int save_flags) {
const char *lpszDstPathName = "raw_exif.jpg";
FIBITMAP *dib = NULL, *dst = NULL;
try {
// load an Exif file (jpeg file)
FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(lpszPathName);
dib = FreeImage_Load(fif, lpszPathName, load_flags);
if(!dib) throw(1);
// check access to raw Exif data
FITAG *tag = NULL;
BOOL bResult = FreeImage_GetMetadata(FIMD_EXIF_RAW, dib, "ExifRaw", &tag);
if(tag) {
const char *key = FreeImage_GetTagKey(tag);
WORD id = FreeImage_GetTagID(tag);
FREE_IMAGE_MDTYPE type = FreeImage_GetTagType(tag);
DWORD count = FreeImage_GetTagCount(tag);
DWORD length = FreeImage_GetTagLength(tag);
BYTE *value = (BYTE*)FreeImage_GetTagValue(tag);
// save as jpeg : Exif data should be preserved
FreeImage_Save(fif, dib, lpszDstPathName, save_flags);
// load and check Exif raw data
fif = FreeImage_GetFileType(lpszDstPathName);
dst = FreeImage_Load(fif, lpszDstPathName, load_flags);
if(!dst) throw(1);
FITAG *dst_tag = NULL;
BOOL bResult = FreeImage_GetMetadata(FIMD_EXIF_RAW, dib, "ExifRaw", &dst_tag);
if(dst_tag) {
const char *key = FreeImage_GetTagKey(dst_tag);
WORD dst_id = FreeImage_GetTagID(dst_tag);
FREE_IMAGE_MDTYPE dst_type = FreeImage_GetTagType(dst_tag);
DWORD dst_count = FreeImage_GetTagCount(dst_tag);
DWORD dst_length = FreeImage_GetTagLength(dst_tag);
BYTE *dst_value = (BYTE*)FreeImage_GetTagValue(dst_tag);
assert(length == dst_length);
}
FreeImage_Unload(dst);
}
FreeImage_Unload(dib);
return TRUE;
}
catch(int) {
if(dib) FreeImage_Unload(dib);
}
return FALSE;
}
// Main test functions
// ----------------------------------------------------------
void testHeaderOnly() {
const char *src_file_jpg = "exif.jpg";
const char *src_file_png = "sample.png";
BOOL bResult = TRUE;
printf("testHeaderOnly ...\n");
testSupportsNoPixels();
// JPEG plugin
bResult = testHeader(src_file_jpg);
assert(bResult);
bResult = testHeaderData(src_file_jpg);
assert(bResult);
// PNG plugin
bResult = testHeader(src_file_png);
assert(bResult);
bResult = testHeaderData(src_file_png);
assert(bResult);
// you cannot save 'header only' FIBITMAP
bResult = testExifRawFile(src_file_jpg, FIF_LOAD_NOPIXELS, 0);
assert(bResult == FALSE);
}
void testExifRaw() {
const char *src_file_jpg = "exif.jpg";
BOOL bResult = TRUE;
printf("testExifRaw ...\n");
// Exif raw metadata loading & saving
// check Exif raw metadata loading & saving
bResult = testExifRawFile(src_file_jpg, 0, 0);
assert(bResult);
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

No description
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LRH158/FreeImage.git
git@gitee.com:LRH158/FreeImage.git
LRH158
FreeImage
FreeImage
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /