十四 QT版本的資料轉換

2021-09-22 12:21:24 字數 2453 閱讀 5794

qstring  stretch_percent_16to8(qstring infilename)

else if (edatatype == 6);

const char *pszwkt = null;

poin->getgeotransform(adfingeotransform);

pszwkt = poin->getprojectionref();

gdaldriver *podriver = (gdaldriver *)gdalgetdriverbyname("gtiff");

gdaldataset *pooutputds = podriver->create(filename.tolocal8bit().data(), src_width, src_height, inbands, gdt_byte, null);

pooutputds->setgeotransform(adfingeotransform);

pooutputds->setprojection(pszwkt);

for (int iband = 0; iband < inbands; iband++)

}for (int src_row = 0; src_row < src_height; src_row++)

return filename;

}else;

const char *pszwkt = null;

poin->getgeotransform(adfingeotransform);

pszwkt = poin->getprojectionref();

gdaldriver *podriver = (gdaldriver *)gdalgetdriverbyname("gtiff");

gdaldataset *pooutputds = podriver->create(filename.tolocal8bit().data(), src_width, src_height, inbands, gdt_byte, null);

pooutputds->setgeotransform(adfingeotransform);

pooutputds->setprojection(pszwkt);

for (int iband = 0; iband < inbands; iband++)

}double *numb_pix = (double *)malloc(sizeof(double)*(src_max + 1));

memset(numb_pix, 0, sizeof(double)* (src_max + 1));

for (int src_row = 0; src_row < src_height; src_row++)

}double *frequency_val = (double *)malloc(sizeof(double)*(src_max + 1));

memset(frequency_val, 0.0, sizeof(double)*(src_max + 1));

for (int val_i = 0; val_i <= src_max; val_i++)

double *accumlt_frequency_val = (double*)malloc(sizeof(double)*(src_max + 1));

memset(accumlt_frequency_val, 0.0, sizeof(double)*(src_max + 1));

for (int val_i = 0; val_i <= src_max; val_i++)

}int minval = 0, maxval = 0;

for (int val_i = 1; val_i < src_max; val_i++)

}for (int val_i = src_max - 1; val_i > 0; val_i--)

}for (int src_row = 0; src_row < src_height; src_row++)

else if (src_temval > maxval)

else

pooutputds->getrasterband(iband + 1)->rasterio(gf_write, 0, src_row, src_width, 1, dstdata, src_width, 1, gdt_byte, 0, 0);

free(dstdata);

}free(numb_pix);

free(frequency_val);

free(accumlt_frequency_val);

free(srcdata);

}gdalclose(poin);

gdalclose(pooutputds);}}

return filename;}}

說明:這個版本,省去了傳統c++中資料開啟的步驟,不容易引起opencv或者是vs版本不同而導致的資料崩潰。完美的結合了qt與opencv、vs、gdal之間的相容性。

QT資料型別轉換

1 char 與 const char 的轉換 char ch1 hello11 const char ch2 hello22 ch2 ch1 不報錯,但有警告 ch1 char ch2 2 char 與 qstring的轉換 char 轉換為 qstring 其實方法有很多中,我用的是 char ...

Qt 資料型別轉換

各種資料型別的相互轉換 char 與 const char 的轉換 char ch1 hello11 const char ch2 hello22 ch2 ch1 不報錯,但有警告 ch1 char ch2 char 轉換為 qstring 其實方法有很多中,我用的是 char a b qstrin...

QT 資料型別轉換

string std str abc qstring q str qstring fromstdstring std str qstring q str abc string q str.tostdstring string std str abc char str std str.c str st...