Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

imread and CString

Okay - I feel really stupid asking this question. But I've fought for this for two days now...

I'm writing in Visual Studio, C++. I'm passing an LPSTR to a function and, in that function, referencing the LPSTR to open a file. But it fails. If I hard-code a value, it succeeds. I'm getting all kinds of typecast warnings. I coded for 12 years but have been out of the business for 16 - so I'm getting back up to speed. Any help would be greatly appreciated!

BOOL CImageDialog::DisplayImage(LPCTSTR pszImageFilePath)
{
    Mat im = imread(pszImageFilePath);

    if (!im.data) {
        return FALSE;
    }
...

Yields:

no suitable constructor exists to convert from "LPCTSTR" to "std::basic_string<char, std::char_traits<char>, std::allocator<char>>"
cv::Mat cv::imread(const std::string &,int)': cannot convert argument 1 from 'LPCTSTR' to 'const std::string &'

I've tried passing other types, but they all cause issues. Thank you in advance!