Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Messages - tyrbo321

Pages: [1]
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.

2
Graphics / Re: Failed to load image from memory, no data provided
« on: December 12, 2015, 10:17:01 pm »
You're very welcome.
Which part helped you, if you don't mind me asking?
This part.
image.loadFromMemory(sfmlIconPngData, 3104);
I don't wrote exact size of array, and tried to load as an image using loadFromFile.

3
Graphics / Re: Failed to load image from memory, no data provided
« on: December 12, 2015, 08:36:04 pm »
i 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.
Thx man, without you I would not have solved the problem

4
Graphics / Re: Failed to load image from memory, no data provided
« on: December 12, 2015, 03:53:51 pm »
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

Thx man, i read about converting the binary file into a header file, and i 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?

5
Graphics / Re: Failed to load image from memory, no data provided
« on: December 12, 2015, 03:18:26 am »
Crap... No resource problem and no file path problem, just dont want load any image from resources. I need working project to know issue.

6
Graphics / Re: Failed to load image from memory, no data provided
« on: December 11, 2015, 11:06:29 pm »
This method works for you, have you ever used it?
If you can, please, make project with that system, and add any resource (just image) on sfml, and give link me, it will be easier to understand the issue. Maybe i have wrong project settings.

7
Graphics / Re: Failed to load image from memory, no data provided
« on: December 11, 2015, 07:52:33 pm »
Since this is the direct result of the following statement failing, it means that either your size or your pointer is 0.

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.
Also im trying use bitmap for load, like in original sample, and again this error, i think i have wrong code.

8
Graphics / [Solved] Failed to load image from memory, no data provided
« on: December 11, 2015, 07:17:37 pm »
I'm using SFML with C++ in VS2012. In debug console i have error "failed to load image from memory, no data provided".



My main.cpp

#include <iostream>
#include "Test.h"
#include "resource.h"
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

using namespace std;

sf::Image LoadImageFromResource(const std::string& name)
{
    HRSRC rsrcData = FindResource(NULL, name.c_str(), RT_RCDATA);

    DWORD rsrcDataSize = SizeofResource(NULL, rsrcData);

    HGLOBAL grsrcData = LoadResource(NULL, rsrcData);

    LPVOID firstByte = LockResource(grsrcData);


    sf::Image image;
    image.loadFromMemory(firstByte, rsrcDataSize);


    return image;
}

int main()
{      
    sf::Image SpriteSheetWalkRes = LoadImageFromResource("IDB_PNG1");
}


My Resource.rc

#define APSTUDIO_READONLY_SYMBOLS

#include "afxres.h"

#undef APSTUDIO_READONLY_SYMBOLS

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT

#ifdef APSTUDIO_INVOKED

1 TEXTINCLUDE
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE
BEGIN
    "\r\n"
    "\0"
END

#endif

IDB_PNG1            RCDATA           "F:\\(...)\\test_player.png"

#endif

#ifndef APSTUDIO_INVOKED

#endif

 


My resource.h

#define IDB_PNG1                        101

#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         40001
#define _APS_NEXT_CONTROL_VALUE         1001
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

9
SFML projects / Re: 'Tiled' Tile-map Loader
« on: July 26, 2015, 04:11:49 pm »
Im fix all, profit  8)

10
SFML projects / Re: 'Tiled' Tile-map Loader
« on: July 24, 2015, 03:10:49 am »
Hi all, again, i do a lot of work, and now i dont have errors, but if i start debug, i have white window, with TestProject has stopped work. I dont know what i need do, and with example maps i have this.

11
SFML projects / Re: 'Tiled' Tile-map Loader
« on: July 22, 2015, 06:22:23 pm »
Sorry XD, i dont load cpp to project. Now i have another error.
error C2065: m_rootNode: undeclared identifier

12
SFML projects / Re: 'Tiled' Tile-map Loader
« on: July 21, 2015, 10:22:33 pm »
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 :(

13
SFML projects / Re: 'Tiled' Tile-map Loader
« on: July 21, 2015, 06:59:06 pm »
Guys?

14
SFML projects / Re: 'Tiled' Tile-map Loader
« on: July 20, 2015, 06:32:52 pm »
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).
Okay, I changed my list of libraries:
sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib
sfml-audio-d.lib
Box2D.lib
tmx-loader-d.lib
pugixmld.lib
zlibd.lib
Now I have everything right with my libs. Those same mistakes XD. Not Surprising

15
SFML projects / Re: 'Tiled' Tile-map Loader
« on: July 20, 2015, 05:11:11 pm »
My libs
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;
Why are you linking debug, release, static-debug, and static-release libraries at the same time?

Sorry for another account, i dont password reset message on mail (dont know why). I am so disappointed in the performance of the library that started doing stupid things. And threw off debug and release and statics connecting them. Your observation is correct, but it generally does not help me to understand the essence of this error.

Pages: [1]