Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pixRead & pixReadWithHint return NULL #699

Open
sinall opened this issue Jun 11, 2023 · 11 comments
Open

pixRead & pixReadWithHint return NULL #699

sinall opened this issue Jun 11, 2023 · 11 comments

Comments

@sinall
Copy link

sinall commented Jun 11, 2023

I'm using 1.83.0 with VC2022 on Windows 11.

pixReadWithHint("captcha-001.bmp", IFF_BMP); returns NULL.

captcha-001.zip

@DanBloomberg
Copy link
Owner

You should only use pixReadWithHint() for jpeg compressed image files. See the documentation.

I have no trouble reading with 1.83 on linux.
What are the error messages?

@sinall
Copy link
Author

sinall commented Jun 11, 2023

You should only use pixReadWithHint() for jpeg compressed image files. See the documentation.

I have no trouble reading with 1.83 on linux. What are the error messages?

That is bmp file, not jpeg. How can I get error message?

@sinall
Copy link
Author

sinall commented Jun 11, 2023

You should only use pixReadWithHint() for jpeg compressed image files. See the documentation.

I have no trouble reading with 1.83 on linux. What are the error messages?

I use leptSetStderrHandler to capture the error:

Error in pixReadMemBmp: 32 bpp rgba input data is not supported

@DanBloomberg
Copy link
Owner

You're right. I enabled handling rgba in bmp after 1.83. If you build from the github master it will work for you.

@sinall
Copy link
Author

sinall commented Jun 12, 2023

You're right. I enabled handling rgba in bmp after 1.83. If you build from the github master it will work for you.

OK, I'm using conan right now, will try when new version is available in Conan.

@sinall
Copy link
Author

sinall commented Jun 12, 2023

@DanBloomberg BTW, is this the correct way to enable exception(or get error)?

void lept_default_stderr_handler(const char *formatted_msg)
{
    throw std::runtime_error(formatted_msg);
}

leptSetStderrHandler(lept_default_stderr_handler);

@DanBloomberg
Copy link
Owner

No, that's a static function that you have modified. See prog/messagetest.c for usage.

@sinall
Copy link
Author

sinall commented Jun 12, 2023

No, that's a static function that you have modified. See prog/messagetest.c for usage.

OK, I can use a different name (e.g CustomErrorHandler) for the function. Is that the correct way to enable exception?

@DanBloomberg
Copy link
Owner

I don't know what you're trying to do. This utility is a messaging system for use when errors occur.
There should be no need to modify or add functions to the library.
Again, see prog/messagetest.c for examples of usage.

@sinall
Copy link
Author

sinall commented Jun 13, 2023

I don't know what you're trying to do. This utility is a messaging system for use when errors occur. There should be no need to modify or add functions to the library. Again, see prog/messagetest.c for examples of usage.

I'm trying to get error message or get exception from leptonica. those code goes to my code not library.
If I don't do that, I can not get error message. For example, the pixRead returns 0, I don't know why!

@DanBloomberg
Copy link
Owner

By default, all error messages go to stderr, so you should see them.
This callback utility just allows you to send the error message to some other stream, or with NULL to skip them.

Again, I suggest you look at the Runtime redirection of stderr in utils1.c, and the examples of usage in prog/messagetest.c.

One more thing. Leptonica also has an elaborate mechanism for controlling the severity of messages that are output.
By default, all info, warning and error messages are output.
This can be changed by the mechanism described in environ.h under
Control printing of error, warning and info messages
and you can do it either on the compiler command line or dynamically during the running of the program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants