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 - Lemon

Pages: [1]
1
Graphics / Loade a png with LoadFromMemory()
« on: January 17, 2010, 11:51:33 pm »
yes have it realized the error. I not really want take 48bit Pictures in my Game. But first I have not seen that the Picture is 48bit and the error tangle my.

2
Graphics / Loade a png with LoadFromMemory()
« on: January 17, 2010, 04:09:28 am »
Something going wrong here!!

my code:
Code: [Select]

    //Lode File from Memory with SFML, and check
    if(false == m_Picture.LoadFromMemory(m_image_c, m_size));
    {
        cout<<"FromFilePNG/ Error: Picture cant by loadet."<<endl;
    }

the false here by the "if-question" can bi false or true, is equal, it coms everitime the  "cout":
Quote

FromFilePNG/ Error: Picture cant by loadet.


I can load the Picture!!
 In the docu is writed, if the return is false, the picture cant by loaded.
 I think ther is a Bug in SFML!!

Sorry for the aspect but it is really strange.

3
Graphics / Loade a png with LoadFromMemory()
« on: January 16, 2010, 03:31:59 pm »
thx for answer!

Quote

And why do you use your own code to load PNG file?

I heart it gives a Function in SFML to loade Pictures binary but the point is I whant make an editor for my game. And I loade the PNG in the editor and save it there binary to loade it again with the game.

I fixed the bug!
Code: [Select]

//Lode PNG with LodePNG and Decode
bool C_PNGFromFile::LoadPNG()
{
    //Lode Image from png-File, and given filename
    LodePNG::loadFile(m_buffer, "Images/Test3.png");
}

//Loade the Picture with SFML and give it back
sf::Image& C_PNGFromFile::GetPicturePNG()
{

    if(m_buffer.size() > 0)
    {
        //Cast from "vector<unsigned char>" to "const char*"
        m_image_c = reinterpret_cast<const char*>(&m_buffer[0]);
        //Get size in Byte's
        m_size = m_buffer.size();
    }

    cout<<"Size: "<<m_size<<endl;
    //Lode File from Memory with SFML, and check
    if(false == m_Picture.LoadFromMemory(m_image_c, m_size));
    {
        cout<<"Error: Picture cant by loadet."<<endl;
    }
    //return the Image
    return m_Picture;
}


I dont have to decode. I dont now wath really is decode. But it works.

I have a question. By some pictures it dont works. The Error is:
Quote

Failed to image font from memory, Reason : PNG not supported: 8-bit only

why this?

EDIT:
The picture there not goes is 48bit. But a picture with 24bit goes.

The error must look like this:
Quote

Failed to image font from memory, Reason : PNG not supported: 8-bit only but 24-bit too ;)

4
Graphics / Loade a png with LoadFromMemory()
« on: January 15, 2010, 07:23:36 pm »
Hello everybody!! My english is nt verygood, but I hope you can understand my.

I have a Library named LodePNG
http://members.gamedev.net/lode/projects/LodePNG/
this library decodes a PNG-picture, and then I want lode it with the function LoadFromMemory().

My code looks like this:

FromFilePNG.hpp
Code: [Select]

#ifndef FROMFILEPNG_HPP_INCLUDED
#define FROMFILEPNG_HPP_INCLUDED

#include <SFML/Graphics.hpp>

#include ".\LodePNG\lodepng.h"

#include <iostream>
using namespace std;

class C_PNGFromFile
{
    private://members for LoadPNG
        vector<unsigned char>m_buffer, m_image;

    private://members for GetPicturePNG
        const char* m_image_c;
        size_t m_size;
        sf::Image m_Picture;

    public://Public Member-Functions
        bool LoadPNG();
        sf::Image& GetPicturePNG();
};

#endif // FROMFILEPNG_HPP_INCLUDED


FromFilePNG.cpp
Code: [Select]

#include "FromFilePNG.hpp"

//Lode PNG with LodePNG and Decode
bool C_PNGFromFile::LoadPNG()
{
    //Lode Image from png-File, and given filename
    LodePNG::loadFile(m_buffer, "Images/Test5.png");

    LodePNG::Decoder decoder;
    //Decode the Image in 32bit
    decoder.decode(m_image, m_buffer);

    //stop if there is an error
    if(decoder.hasError())
    {
      cout <<"error: "<<decoder.getError()<<endl;
      return false;
    }
    return true;

}

//Loade the Picture with SFML and give it back
sf::Image& C_PNGFromFile::GetPicturePNG()
{

    if(m_image.size() > 0)
    {
        //Cast from "vector<unsigned char>" to "const char*"
        m_image_c = reinterpret_cast<const char*>(&m_image[0]);
        //Get size in Byte's
        m_size = m_image.size();
    }

    cout<<"Size: "<<m_size<<endl;

    //Lode File from Memory with SFML, and check
    if(false == m_Picture.LoadFromMemory(m_image_c, m_size));
    {
        cout<<"Error: Picture cant by loadet."<<endl;
    }
    //return the Image
    return m_Picture;
}


I dont know whats going wrong here

In the Shell-Window, I can read:
Quote

Size: 1228800
Failed to load image from memory. Reason : Image not of any known type, or corrupt
Error: Picture cant by loadet.


Has anyone an idea, whats going wrong?

Pages: [1]
anything