[英]GenICam::gcstring from int
我正在使用 Basler 的 Pylon 庫,它是 GenICam 的擴展。
他們在那里定義了一個用於保存圖像的函數:
virtual void Save (EImageFileFormat imageFileFormat, const String_t &filename, CImagePersistenceOptions *pOptions=NULL) const
其中 String_t 是 GenICam::gcstring 的擴展
有關 gcstring 的信息如下:
Portable string implementation. More...
#include <new>
#include <string>
#include <iostream>
#include <Base/GCTypes.h>
Classes
class GenICam::gcstring
A string class which is a clone of std::string. More...
Namespaces
GenICam
Contains definitions of GenICam types and exceptions.
Macros
#define GCSTRING_NPOS size_t(-1)
Indicates either 'not found' or 'all remaining characters'.
Functions
std::istream & GenICam::getline (std::istream &is, GenICam::gcstring &str)
std::istream & GenICam::getline (std::istream &is, GenICam::gcstring &str, char delim)
std::ostream & operator<< (std::ostream &ostr, const GenICam::gcstring &str)
std::istream & operator>> (std::istream &istr, GenICam::gcstring &str)
我需要使用從 long int 生成的文件名保存圖像,我嘗試了很多方法但都失敗了,誰能提供幫助?
對於仍在尋找答案的任何人,String_t 接受一個 const char 數組作為輸入。 因此,您可以簡單地將long
轉換為std::string
,然后將string.c_str()
傳遞給String_t
構造函數。
因此,要從 long 轉換為std::string
請執行以下操作:
#include <string>
long myNumber = getNumber();
std::string s = std::to_string(myNumber);
然后你可以像這樣保存圖像:
CImagePersistence::Save(ImageFileFormat_Tiff, String_t(s.c_str()), *image);
注意:我正在使用 pylon 5。
請使用以下方法。
char char_arr [100];
long int num = 10;
sprintf(char_arr, "%d", num);
String_t stringValue(char_arr);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.