Error Loading Image, NoDecodeDelegateForThisImageFormat

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
TheProfessor
Posts: 8
Joined: 2014-04-11T10:14:47-07:00
Authentication code: 6789

Error Loading Image, NoDecodeDelegateForThisImageFormat

Post by TheProfessor »

I am trying to use ImageMagick as part of a model loading code to load a texture for a mesh from blender. The file itself is some 1 pixel sized white dot.

Here's the code:

Mesh.cpp

Code: Select all

bool Mesh::InitMaterials(const aiScene* pScene, const std::string& Filename)
{
	// Extract the directory part from the file name
	std::string::size_type SlashIndex = Filename.find_last_of("/");
	std::string Dir;

	if (SlashIndex == std::string::npos) {
		Dir = ".";
	}
	else if (SlashIndex == 0) {
		Dir = "/";
	}
	else {
		Dir = Filename.substr(0, SlashIndex);
	}

	bool Ret = true;

	// Initialize the materials
	for (unsigned int i = 0; i < pScene->mNumMaterials; i++) {
		const aiMaterial* pMaterial = pScene->mMaterials[i];

		m_Textures[i] = NULL;
		if (pMaterial->GetTextureCount(aiTextureType_DIFFUSE) > 0) {
			aiString Path;

			if (pMaterial->GetTexture(aiTextureType_DIFFUSE, 0, &Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) {
				std::string FullPath = Dir + "/" + Path.data;
				m_Textures[i] = new Texture(GL_TEXTURE_2D, FullPath.c_str());

				if (!m_Textures[i]->Load()) {
					printf("Error loading texture '%s'\n", FullPath.c_str());
					delete m_Textures[i];
					m_Textures[i] = NULL;
					Ret = false;
				}
				else {
					printf("Loaded texture '%s'\n", FullPath.c_str());
				}
			}
		}

		// Load a white texture in case the model does not include its own texture
		if (!m_Textures[i]) {
			m_Textures[i] = new Texture(GL_TEXTURE_2D, "/Resources/white.jpg");

			Ret = m_Textures[i]->Load();
		}
	}

	return Ret;
}

Texture.cpp:

Code: Select all

bool Texture::Load()
{
    try {
        m_pImage = new Magick::Image(m_fileName);
        m_pImage->write(&m_blob, "RGBA");
    }
    catch (Magick::Error& Error) {
        std::cout << "Error loading texture '" << m_fileName << "': " << Error.what() << std::endl;
        return false;
    }

    glGenTextures(1, &m_textureObj);
    glBindTexture(m_textureTarget, m_textureObj);
    glTexImage2D(m_textureTarget, 0, GL_RGBA, m_pImage->columns(), m_pImage->rows(), 0, GL_RGBA, GL_UNSIGNED_BYTE, m_blob.data());
    glTexParameterf(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameterf(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    return true;
}
I'll try getting the imagemagick code and installing/compiling it instead of using the includes and libs provided in the tutorial source code but otherwise whats going wrong?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error Loading Image, NoDecodeDelegateForThisImageFormat

Post by fmw42 »

What is the exact error message? It would appear that you are missing some delegate library associated with reading or writing to a particular image format. What version of IM and platform? You can check with

convert -version

That will also show you a list of delegates if your version of IM is recent enough.
TheProfessor
Posts: 8
Joined: 2014-04-11T10:14:47-07:00
Authentication code: 6789

Re: Error Loading Image, NoDecodeDelegateForThisImageFormat

Post by TheProfessor »

fmw42 wrote:What is the exact error message? It would appear that you are missing some delegate library associated with reading or writing to a particular image format. What version of IM and platform? You can check with

convert -version

That will also show you a list of delegates if your version of IM is recent enough.
IIRC the title of the thread is the error message, otherwise its "Error loading image '[path-to-file]'.


entering "convert -version" lists me a bunch of image file extensions including png, so it should be supported.

This is on windows, I'm trying to use the version of it that came with the source code of the tutorial I am following.

http://ogldev.atspace.co.uk/www/tutoria ... ial16.html

Is the tutorial.

I love how his link to the "instructions" says nothing about how to install and use image magick, so I'm navigating blind. :allears:
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error Loading Image, NoDecodeDelegateForThisImageFormat

Post by fmw42 »

Perhaps you should install from the official IM binaries. See http://www.imagemagick.org/script/binar ... hp#windows

What do you get from the command line for

convert logo: logo.png

convert logo.png logo.gif

convert logo.png logo.jpg

Do they all work?
TheProfessor
Posts: 8
Joined: 2014-04-11T10:14:47-07:00
Authentication code: 6789

Re: Error Loading Image, NoDecodeDelegateForThisImageFormat

Post by TheProfessor »

fmw42 wrote:Perhaps you should install from the official IM binaries. See http://www.imagemagick.org/script/binar ... hp#windows

What do you get from the command line for

convert logo: logo.png

convert logo.png logo.gif

convert logo.png logo.jpg

Do they all work?
I'm not sure, I'll try it in a moment but I want to clarify something, I want to include ImageMagick into my VS2013 Project, I need an includes folder and probably your lib folder, which link gives me those pre-compiled?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Error Loading Image, NoDecodeDelegateForThisImageFormat

Post by fmw42 »

Sorry I do not use or know much about Windows and IM installs for Windows. Perhaps one of the Windows user can help further. I was just trying to have you check if your install was valid.
Post Reply