本文整理汇总了C++中PNG::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ PNG::clear方法的具体用法?C++ PNG::clear怎么用?C++ PNG::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PNG
的用法示例。
在下文中一共展示了PNG::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromFiles
bool CTdata::loadFromFiles(const char * filename, int cnt, int scaleX, int scaleY, int scaleZ){
int divide = 2;
int chars = 0;
scX = scaleX;
scY = scaleY;
scZ = scaleZ/divide;
char filen [50];
unsigned char * rawData;
PNG ctfile;
int width=0, height=0, width2, height2;
int x,y,z;
float val;
for(z=0; z<cnt; z++){
sprintf(filen, filename, z+1);
ctfile.clear();
if (!ctfile.load(filen)){
return false;
}
rawData = ctfile.getData();
height = ctfile.height;
width = ctfile.width;
width2 = width/float(divide);
height2 = height/float(divide);
if (data==NULL){
data = new float[cnt*width2*height2]; //data = new float[cnt*width*height];
}
for (y=0; y<height2; y++){ //height
for (x=0; x<width2; x++){ //width
// 2x 8-bit to 1x 16-bit
val = 256*rawData[(2*y*width + 2*x)*divide]+rawData[(2*y*width + 2*x)*divide + 1]; //val = 256*rawData[2*y*width + 2*x]+rawData[2*y*width + 2*x + 1];
// save in array
data[z*height2*width2 + y*width2 +(width2-1-x)] = val; //data[z*width*height + y*width +x] = val;
}
}
BACKSPACE(chars);
chars = printf("LOADING CT images: %03i %%",((z+1)*100)/cnt);
}
dimX = width2;
dimY = height2;
dimZ = cnt;
szX = dimX * scX;
szY = dimY * scY;
szZ = dimZ * scZ;
center.x = szX/2.0;
center.y = szY/2.0;
center.z = szZ/2.0;
// backspace...
BACKSPACE(chars);
printf("LOADING CT images (%i) DONE\n", cnt);
return true;
}