1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 03:35:09 +00:00

LibGfx+LibWeb: Add JPEG decoder and integrate with LibWeb

This patch adds support for JPEG decoding. The JPEG decoder is capable
of handling standard 2x1 horizontal, 2x1 vertical and quartered chroma
subsampling. The implemented Inverse DCT performs with a decent speed.

As of interchange formats, since we tend to ignore the metadata in APPn
markers, the decoder can handle any format compatible with JFIF, which
includes EXIFs and sometimes WebMs too. The decoder does not support
progressive JPEGs yet.
This commit is contained in:
Devashish 2020-05-18 13:28:27 +05:30 committed by Andreas Kling
parent 10255bc5c6
commit 8b71b839fa
12 changed files with 1301 additions and 8 deletions

View file

@ -79,21 +79,24 @@ String mime_type_from_content_type(const String& content_type)
static String guess_mime_type_based_on_filename(const URL& url)
{
if (url.path().ends_with(".pbm"))
String lowercase_url = url.path().to_lowercase();
if (lowercase_url.ends_with(".pbm"))
return "image/xportablebitmap";
if (url.path().ends_with(".png"))
if (lowercase_url.ends_with(".png"))
return "image/png";
if (url.path().ends_with(".ppm"))
if (lowercase_url.ends_with(".ppm"))
return "image/xportablepixmap";
if (url.path().ends_with(".gif"))
if (lowercase_url.ends_with(".gif"))
return "image/gif";
if (url.path().ends_with(".bmp"))
if (lowercase_url.ends_with(".bmp"))
return "image/bmp";
if (url.path().ends_with(".md"))
if (lowercase_url.ends_with(".jpg") || lowercase_url.ends_with(".jpeg"))
return "image/jpeg";
if (lowercase_url.ends_with(".md"))
return "text/markdown";
if (url.path().ends_with(".html") || url.path().ends_with(".htm"))
if (lowercase_url.ends_with(".html") || lowercase_url.ends_with(".htm"))
return "text/html";
if (url.path().ends_with("/"))
if (lowercase_url.ends_with("/"))
return "text/html";
return "text/plain";
}