本文整理汇总了C++中wxImage::LoadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ wxImage::LoadFile方法的具体用法?C++ wxImage::LoadFile怎么用?C++ wxImage::LoadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxImage
的用法示例。
在下文中一共展示了wxImage::LoadFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFile
bool GOrgueBitmapCache::loadFile(wxImage& img, wxString filename)
{
GOrgueFilename name;
name.Assign(filename, m_organfile);
std::unique_ptr<GOrgueFile> file = name.Open();
if (!file->Open())
return false;
unsigned length = file->GetSize();
char* data = (char*)malloc(length);
if (!data)
throw GOrgueOutOfMemory();
if (file->Read(data, length) != length)
{
free(data);
return false;
}
file->Close();
wxMemoryInputStream is(data, length);
bool result = img.LoadFile(is, wxBITMAP_TYPE_ANY, -1);
free(data);
return result;
}
示例2: wxBitmap
bool BM2CMP_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
// Prj().MaybeLoadProjectSettings();
m_BitmapFileName = aFileSet[0];
if( !m_Pict_Image.LoadFile( m_BitmapFileName ) )
{
// LoadFile has its own UI, no need for further failure notification here
return false;
}
m_Pict_Bitmap = wxBitmap( m_Pict_Image );
int h = m_Pict_Bitmap.GetHeight();
int w = m_Pict_Bitmap.GetWidth();
// Determine image resolution in DPI (does not existing in all formats).
// the resolution can be given in bit per inches or bit per cm in file
m_imageDPI.x = m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
m_imageDPI.y = m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
if( m_imageDPI.x > 1 && m_imageDPI.y > 1 )
{
if( m_Pict_Image.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT ) == wxIMAGE_RESOLUTION_CM )
{
// When the initial resolution is given in bits per cm,
// experience shows adding 1.27 to the resolution converted in dpi
// before convert to int value reduce the conversion error
// but it is not perfect
m_imageDPI.x = m_imageDPI.x * 2.54 + 1.27;
m_imageDPI.y = m_imageDPI.y * 2.54 + 1.27;
}
}
else // fallback to the default value
m_imageDPI.x = m_imageDPI.y = DEFAULT_DPI;
// Display image info:
// We are using ChangeValue here to avoid generating a wxEVT_TEXT event.
m_DPIValueX->ChangeValue( wxString::Format( wxT( "%d" ), m_imageDPI.x ) );
m_DPIValueY->ChangeValue( wxString::Format( wxT( "%d" ), m_imageDPI.y ) );
updateImageInfo();
m_InitialPicturePanel->SetVirtualSize( w, h );
m_GreyscalePicturePanel->SetVirtualSize( w, h );
m_BNPicturePanel->SetVirtualSize( w, h );
m_Greyscale_Image.Destroy();
m_Greyscale_Image = m_Pict_Image.ConvertToGreyscale( );
if( m_rbOptions->GetSelection() > 0 )
NegateGreyscaleImage( );
m_Greyscale_Bitmap = wxBitmap( m_Greyscale_Image );
m_NB_Image = m_Greyscale_Image;
Binarize( (double) m_sliderThreshold->GetValue()/m_sliderThreshold->GetMax() );
return true;
}
示例3: setUp
void AffineTransformTestCase::setUp()
{
#if wxUSE_DC_TRANSFORM_MATRIX
m_imgOrig.LoadFile("horse.jpg");
CPPUNIT_ASSERT( m_imgOrig.IsOk() );
m_bmpOrig = wxBitmap(m_imgOrig);
#endif // wxUSE_DC_TRANSFORM_MATRIX
}
示例4: wxLogWarning
bool
hoxUtil::LoadBoardImage( const wxString& sImage,
wxImage& image,
hoxBoardImageInfo& imageInfo )
{
const wxString sPrefixPath = hoxUtil::GetPath(hoxRT_BOARD);
const wxString sIniFile = sPrefixPath + sImage.BeforeFirst('.') + ".ini";
hoxUtil::LoadBoardInfo( sIniFile, imageInfo );
const wxString imageFile = sPrefixPath + sImage;
if ( ! image.LoadFile(imageFile, wxBITMAP_TYPE_PNG) )
{
wxLogWarning("%s: Failed to load board-image from [%s].", __FUNCTION__, imageFile.c_str());
return false;
}
return true;
}
示例5: LoadUserImage
wxString MyFrame::LoadUserImage(wxImage& image)
{
wxString filename;
#if wxUSE_FILEDLG
filename = wxLoadFileSelector(wxT("image"), wxEmptyString);
if ( !filename.empty() )
{
if ( !image.LoadFile(filename) )
{
wxLogError(wxT("Couldn't load image from '%s'."), filename.c_str());
return wxEmptyString;
}
}
#endif // wxUSE_FILEDLG
return filename;
}
示例6: wxLogError
hoxResult
hoxUtil::LoadPieceImage( const wxString& sPath,
hoxPieceType type,
hoxColor color,
wxImage& image)
{
const wxString sPrefixPath = hoxUtil::GetPath(hoxRT_PIECE) + "/" + sPath;
const wxChar cColor = (color == hoxCOLOR_RED ? 'r' : 'b');
const wxString imageName = _piece_type_to_image_name( type );
const wxString sFullPath =
wxString::Format("%s/%c%s", sPrefixPath.c_str(), cColor, imageName.c_str());
if ( ! image.LoadFile(sFullPath, wxBITMAP_TYPE_PNG) )
{
wxLogError("%s: Failed to load piece from [%s].", __FUNCTION__, sFullPath.c_str());
return hoxRC_ERR;
}
return hoxRC_OK;
}
示例7: Piano_load_shapes
//all shapes are loaded from same image file to reduce file I/O and caching
//thiss also allows animated images to be self-contained
void PianoRenderCache::Piano_load_shapes(RenderBuffer &buffer, const wxString& filename)
{
debug_function(10); //Debug debug("load_shapes('%s')", (const char*)filename.c_str());
debug(1, "load shapes file '%s'", (const char*)filename.c_str());
//reload shapes even if file name hasn't changed; color map might be different now
// if (!CachedShapeFilename.CmpNoCase(filename)) { debug_more(2, ", no change"); return; } //no change
if (!wxFileExists(filename)) return;
Piano_flush_shapes(); //invalidate cached data
if (!Shapes.LoadFile(filename, wxBITMAP_TYPE_ANY, 0) || !Shapes.IsOk())
{
//wxMessageBox("Error loading image file: "+NewPictureName);
Shapes.Clear();
return;
}
if (buffer.GetColorCount() < 2) return; //use colors from shapes file if no user-selected colors
// int imgwidth=image.GetWidth();
// int imght =image.GetHeight();
// std::hash_map<WXCOLORREF, int> palcounts;
//TODO: use wxImage.GetData for better performance?
//TODO: use multiple images within same file?
for (int y = Shapes.GetHeight() - 1; y >= 0; --y) //bottom->top
for (int x = 0; x < Shapes.GetWidth(); ++x) //left->right
if (!Shapes.IsTransparent(x, y))
{
xlColor color, mapped;
color.Set(Shapes.GetRed(x, y), Shapes.GetGreen(x, y), Shapes.GetBlue(x, y));
if (ColorMap.find(color.GetRGB()) != ColorMap.end()) continue; //already saw this color
buffer.palette.GetColor(ColorMap.size() % buffer.GetColorCount(), mapped); //assign user-selected colors to shape palette sequentially, loop if run out of colors
debug(10, "shape color[%d] 0x%x => user-selected color [%d] 0x%x", ColorMap.size(), color.GetRGB(), ColorMap.size() % GetColorCount(), mapped.GetRGB());
ColorMap[color.GetRGB()] = mapped; //.GetRGB();
// ShapePalette.push_back(c.GetRGB()); //keep a list of unique colors in order of occurrence from origin L-R, B-T
}
debug(2, "w %d, h %d, #colors %d", Shapes.GetWidth(), Shapes.GetHeight(), ColorMap.size());
CachedShapeFilename = filename; //don't load same file again
}
示例8: createPreview
bool PreviewGeneratorThread::createPreview(wxImage &localPreviewImage, PreviewInfo &previewInfo)
{
bool fileReadOK = false;
{
wxImage image2;
// Temporarily switch off logging errors for component wx
// This is to prevent telling the user in a pop-up window that loading a
// malformed JPEG for the preview did not work
wxLogLevel prevLevel = wxLog::GetLogLevel();
#if wxCHECK_VERSION(2, 9, 0)
wxLog::SetComponentLevel(wxT("wx"), wxLOG_FatalError);
#else
wxLog::SetLogLevel(wxLOG_FatalError);
#endif
// Load JPEG image
fileReadOK = localPreviewImage.LoadFile(previewInfo.filename1_, wxBITMAP_TYPE_JPEG); // TODO: Allow all types ... ?
if(!previewInfo.filename2_.IsEmpty())
{
fileReadOK = image2.LoadFile(previewInfo.filename2_, wxBITMAP_TYPE_JPEG); // TODO: Allow all types ... ?
}
#if wxCHECK_VERSION(2, 9, 0)
wxLog::SetComponentLevel(wxT("wx"), prevLevel);
#else
wxLog::SetLogLevel(prevLevel);
#endif
if(previewInfo.type_ == PreviewInfo::PITKeypoints
&& previewInfo.keypointType_ != PreviewInfo::PIKPTNoKeypoints
&& !previewInfo.kpFilename1_.IsEmpty())
{
// Load features from file
Regard3DFeatures::FeatsR3D features;
std::string kpfilename(previewInfo.kpFilename1_.mb_str());
if(openMVG::features::loadFeatsFromFile(kpfilename, features))
{
// Convert to OpenCV keypoints
std::vector< cv::KeyPoint > vec_keypoints;
vec_keypoints.reserve(features.size());
for(size_t i = 0; i < features.size(); i++)
{
const Regard3DFeatures::FeatureR3D &ft = features[i];
vec_keypoints.push_back( cv::KeyPoint( ft.x(), ft.y(), ft.scale() * 2.0f, ft.orientation() ) );
}
// Convert image to OpenCV
cv::Mat img_cv;
OpenCVHelper::convertWxImageToCVMat(localPreviewImage, img_cv);
// Add keypoints to image
cv::Mat img_outcv;
int flags = cv::DrawMatchesFlags::DEFAULT;
if(previewInfo.keypointType_ == PreviewInfo::PIKPTRichKeypoints)
flags = cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS;
cv::drawKeypoints(img_cv, vec_keypoints, img_outcv, cv::Scalar::all(-1), flags);
//cv::imwrite("img_outcv.png", img_outcv);
// Copy back to wxImage
OpenCVHelper::convertCVMatToWxImage(img_outcv, localPreviewImage);
}
}
if(previewInfo.type_ == PreviewInfo::PITMatches)
{
if(previewInfo.keypointType_ != PreviewInfo::PIKPTNoKeypoints
&& !previewInfo.matchesFilename_.IsEmpty())
{
// Load features from file
std::vector< cv::KeyPoint > vec_keypoints1, vec_keypoints2;
Regard3DFeatures::FeatsR3D features;
std::string kpfilename(previewInfo.kpFilename1_.mb_str());
if(openMVG::features::loadFeatsFromFile(kpfilename, features))
{
// Convert to OpenCV keypoints
vec_keypoints1.reserve(features.size());
for(size_t i = 0; i < features.size(); i++)
{
const Regard3DFeatures::FeatureR3D &ft = features[i];
vec_keypoints1.push_back( cv::KeyPoint( ft.x(), ft.y(), ft.scale() * 2.0f, ft.orientation() ) );
}
}
features.clear();
kpfilename = previewInfo.kpFilename2_.mb_str();
if(openMVG::features::loadFeatsFromFile(kpfilename, features))
{
// Convert to OpenCV keypoints
vec_keypoints2.reserve(features.size());
for(size_t i = 0; i < features.size(); i++)
{
const Regard3DFeatures::FeatureR3D &ft = features[i];
vec_keypoints2.push_back( cv::KeyPoint( ft.x(), ft.y(), ft.scale() * 2.0f, ft.orientation() ) );
}
}
// Load matches from file
std::string sMatchFile(previewInfo.matchesFilename_.mb_str());
openMVG::matching::PairWiseMatches map_Matches;
openMVG::matching::PairedIndMatchImport(sMatchFile, map_Matches);
//.........这里部分代码省略.........