mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +00:00
LibGfx: Re-work the abstractions of sending image for decoding over IPC
Originally I simply thought that passing file paths is quite OK, but as Linus pointed to, it turned out that passing file paths to ensure some files are able to be decoded is awkward because it does not work with images being served over HTTP. Therefore, ideally we should just use the MIME type as an optional argument to ensure that we can always fallback to use that in case sniffing for the correct image type has failed so we can still detect files like with the TGA format, which has no magic bytes.
This commit is contained in:
parent
fedd18eb89
commit
6e6999ce57
11 changed files with 34 additions and 91 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/MimeData.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
|
@ -167,8 +168,8 @@ void ViewWidget::load_from_file(DeprecatedString const& path)
|
|||
|
||||
// Spawn a new ImageDecoder service process and connect to it.
|
||||
auto client = ImageDecoderClient::Client::try_create().release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
auto decoded_image_or_error = client->decode_image_with_known_path(path, mapped_file.bytes());
|
||||
auto mime_type = Core::guess_mime_type_based_on_filename(path);
|
||||
auto decoded_image_or_error = client->decode_image(mapped_file.bytes(), mime_type);
|
||||
if (!decoded_image_or_error.has_value()) {
|
||||
show_error();
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue