Skip to content

Commit

Permalink
LibGfx+LibWeb: Add JPEG decoder and integrate with LibWeb
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
devsh0 authored and awesomekling committed Jun 23, 2020
1 parent 10255bc commit 8b71b83
Show file tree
Hide file tree
Showing 12 changed files with 1,301 additions and 8 deletions.
23 changes: 23 additions & 0 deletions Base/res/html/misc/jpg.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pretty JPEG Pictures</title>
</head>
<body>
<div>
<h3>Non-subsampled Lena</h3> <br>
<img alt="lena" src="jpgsuite_files/non-subsampled-lena.jpg"/> <br>
<h3>Chroma Horizontally Halved Lena</h3> <br>
<img alt="lena" src="jpgsuite_files/horizontally-halved-lena.jpg"/> <br>
<h3>Chroma Vertically Halved Lena</h3> <br>
<img alt="lena" src="jpgsuite_files/vertically-halved-lena.jpg"/> <br>
<h3>Chroma Quartered Lena</h3> <br>
<img alt="lena" src="jpgsuite_files/chroma-quartered-lena.jpg"/><br>
</div>
<div>
<h3>Oh Lena!</h3> <br>
<img alt="lena" src="jpgsuite_files/oh-lena.jpg"/>
</div>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Base/res/html/misc/jpgsuite_files/oh-lena.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Base/res/html/misc/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ <h1>Welcome to the Serenity Browser!</h1>
<li><a href="iframe.html">iframe</a></li>
<li><a href="many-buggies.html">many buggies</a></li>
<li><a href="bmpsuite.html">BMP test suite</a></li>
<li><a href="jpg.html">JPG Images</a></li>
<li><a href="palette.html">system palette color css extension</a></li>
<li><a href="inline-block-link.html">link inside display: inline-block</a></li>
<li><a href="set-interval.html">setInterval() test</a></li>
Expand Down
1 change: 1 addition & 0 deletions Libraries/LibGfx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(SOURCES
GIFLoader.cpp
ICOLoader.cpp
ImageDecoder.cpp
JPGLoader.cpp
Painter.cpp
Palette.cpp
Path.cpp
Expand Down
6 changes: 6 additions & 0 deletions Libraries/LibGfx/ImageDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <LibGfx/GIFLoader.h>
#include <LibGfx/ICOLoader.h>
#include <LibGfx/ImageDecoder.h>
#include <LibGfx/JPGLoader.h>
#include <LibGfx/PBMLoader.h>
#include <LibGfx/PNGLoader.h>
#include <LibGfx/PPMLoader.h>
Expand Down Expand Up @@ -60,7 +61,12 @@ ImageDecoder::ImageDecoder(const u8* data, size_t size)
if (m_plugin->sniff())
return;

m_plugin = make<JPGImageDecoderPlugin>(data, size);
if (m_plugin->sniff())
return;

m_plugin = nullptr;
return;
}

ImageDecoder::~ImageDecoder()
Expand Down
Loading

0 comments on commit 8b71b83

Please sign in to comment.