MCPcopy Create free account
hub / github.com/XiaoBaiiiiii/colmap-pcd / LoadImageFile

Method LoadImageFile

lib/SiftGPU/GLTexImage.cpp:1081–1185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1079
1080
1081int GLTexInput::LoadImageFile(char *imagepath, int &w, int &h )
1082{
1083#ifndef SIFTGPU_NO_DEVIL
1084 static int devil_loaded = 0;
1085 unsigned int imID;
1086 int done = 1;
1087
1088 if(devil_loaded == 0)
1089 {
1090 ilInit();
1091 ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
1092 ilEnable(IL_ORIGIN_SET);
1093 devil_loaded = 1;
1094 }
1095
1096 ///
1097 ilGenImages(1, &imID);
1098 ilBindImage(imID);
1099
1100 if(ilLoadImage(imagepath))
1101 {
1102 w = ilGetInteger(IL_IMAGE_WIDTH);
1103 h = ilGetInteger(IL_IMAGE_HEIGHT);
1104 int ilformat = ilGetInteger(IL_IMAGE_FORMAT);
1105
1106 if(SetImageData(w, h, ilGetData(), ilformat, GL_UNSIGNED_BYTE)==0)
1107 {
1108 done =0;
1109 }else if(GlobalUtil::_verbose)
1110 {
1111 std::cout<<"Image loaded :\t"<<imagepath<<"\n";
1112 }
1113
1114 }else
1115 {
1116 std::cerr<<"Unable to open image [code = "<<ilGetError()<<"]\n";
1117 done = 0;
1118 }
1119
1120 ilDeleteImages(1, &imID);
1121
1122 return done;
1123#else
1124 FILE * file = fopen(imagepath, "rb"); if (file ==NULL) return 0;
1125
1126 char buf[8]; int width, height, cn, g, done = 1;
1127
1128 if(fscanf(file, "%s %d %d %d", buf, &width, &height, &cn )<4 || cn > 255 || width < 0 || height < 0)
1129 {
1130 fclose(file);
1131 std::cerr << "ERROR: fileformat not supported\n";
1132 return 0;
1133 }else
1134 {
1135 w = width;
1136 h = height;
1137 }
1138 unsigned char * data = new unsigned char[width * height];

Callers 1

RunSIFTMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected