1
Graphics / Re: Failed to load image from memory, no data provided
« on: December 12, 2015, 10:23:32 pm »
Also, thank you to everyone who took the time my problem.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
You're very welcome.This part.
Which part helped you, if you don't mind me asking?
Thx man, without you I would not have solved the problemi convert my png to .h now, but i cant find examples, and manuals how open it as image. I include .h now, ok, but as i try load it as image it does not work (not surprising). Maybe my question stupid, but how?There has been talks of this on the forum before but I can't remember where.
Here's a simple example of how to load an image file from a header into an sf::Image:#include <SFML/Graphics.hpp>
#include "icon_png.hpp"
int main()
{
sf::Image image;
image.loadFromMemory(sfmlIconPngData, 3104); // exact size of array
sf::RenderWindow window(sf::VideoMode(300, 16), "Include Image File As Header", sf::Style::Default);
sf::Texture texture;
texture.loadFromImage(image);
sf::Sprite sprite(texture);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(sprite);
window.display();
}
return EXIT_SUCCESS;
}
The header (icon_png.hpp) is attached.
I don't fully understand what you mean. Did that help?just dont want load any image from resources.If your goal is to avoid having separate files, you can link them into your executable without using Microsoft's resources. A simple way is to convert the binary file into a header file - with an array of the data - that can be linked into your project and built into your executable. This has the added benefit that it also allows your project to be cross-platform.
If you would prefer to continue with Microsoft's resource manager, you may find what you need here:
ICON resource
BITMAP resource
Since this is the direct result of the following statement failing, it means that either your size or your pointer is 0.Also im trying use bitmap for load, like in original sample, and again this error, i think i have wrong code.
if (data && dataSize)
It's always a good advice to run your code in a debugger and/or printing the variables out, to verify their content.
An idea is to fill the remaining space automatically. This means that you dont use tiles for the outerspace.I try load map from example, dont work. And this is not Debug error
Okay, I changed my list of libraries:Your observation is correct, but it generally does not help me to understand the essence of this error.If you're linking incorrectly, you'll get incorrect linking errors.
Only link the libraries for the build type that you are using (e.g. compiler, 32/64-bit, debug/release, static/dynamic).
My libsWhy are you linking debug, release, static-debug, and static-release libraries at the same time?
sfml-graphics-d.lib;sfml-window-d.lib;sfml-system-d.lib;sfml-audio-d.lib;sfml-graphics-s.lib;sfml-window-s.lib;sfml-system-s.lib;sfml-audio-s.lib;sfml-graphics-s-d.lib;sfml-window-s-d.lib;sfml-system-s-d.lib;sfml-audio-s-d.lib;Box2D.lib;tmx-loader-d.lib;tmx-loader.lib;pugixmls.lib;pugixmld.lib;zlibd.lib;freetype.lib;jpeg.lib;glew32.lib;opengl32.lib;zlibstatic.lib;