void InputManager::addDevice( InputDevice* device ) { if( !device ) { LogWarn( "Tried to add an invalid input device" ); return; } devices.push_back( device ); LogInfo( "Registered a new input device: '%s'", EnumGetValueName(ReflectionGetType(InputDeviceType), (int32)device->getType())); }
wxBitmap* ConvertImageToBitmap( Image* image, const Path& fullPath ) { if( !image || !image->isLoaded() ) return nullptr; PixelFormat pf = image->getPixelFormat(); if( pf != PixelFormat::R8G8B8A8 ) { LogDebug("Invalid image format: %s", EnumGetValueName(ReflectionGetType(PixelFormat), (int32)pf)); return nullptr; } //wxBitmap* bmp = new wxBitmap; //bmp->Create(&image->getBuffer(), wxBITMAP_TYPE_ANY, image->getWidth(), image->getHeight(), 4); Stream* stream = StreamCreateFromFile(AllocatorGetHeap(), fullPath, StreamOpenMode::Read); if( !stream ) return nullptr; std::vector<byte> data; StreamRead(stream, data); wxMemoryInputStream mem(&data[0], data.size()); wxImage img(mem); img.Rescale(32, 32); StreamDestroy(stream); #if 0 const wxSize& size = GetSize(); if( img.GetWidth() > size.GetWidth() || img.GetHeight() > size.GetHeight() ) { img.Rescale( size.GetWidth(), size.GetHeight() ); } #endif wxBitmap* bmp = new wxBitmap(img); return bmp; }
void Image::log() const { const char* desc = EnumGetValueName(PixelFormatGetType(), (int32)format); LogInfo( "Image has pixel format '%s' and size %dx%d", desc, width, height ); }