1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:38:10 +00:00
serenity/Userland/Libraries/LibGfx
Nico Weber 926c0d8676 ICC+image: Add conversion between color spaces for images :^)
For now, only for color spaces that are supported by Profile::to_pcs()
and Profile::from_pcs(), which currently means that all matrix profiles
(but not LUT profiles) in the source color space work, and that
matrix profiles with parametric curves in the destination color
space work.

This adds Profile::convert_image(Bitmap, source_profile), and
adds a `--convert-to-color-profile file.icc` flag to `image`.

It only takes a file path, so to use it with the built-in
sRGB profile, you have to write it to a file first:

% Build/lagom/icc -n sRGB --reencode-to serenity-sRGB.icc

`image` by default writes the source image's color profile
to the output image, and most image viewers display images
looking at the profile.

For example, take `Seven_Coloured_Pencils_(rg-switch_sRGB).jpg`
from https://commons.wikimedia.org/wiki/User:Colin/BrowserTest.

It looks normal in image viewers because they apply the unusual
profile embedded in the profile. But if you run

% Build/lagom/image -o huh.png --strip-color-profile \
    'Seven_Coloured_Pencils_(rg-switch_sRGB).jpeg'

and then look at huh.png, you can see how the image's colors
look like when interpreted as sRGB (which is the color space
PNG data is in if the PNG doesn't store an embedded profile).

If you now run

% Build/lagom/image -o wow.png \
    --convert-to-color-profile serenity-sRGB.icc --strip-color-profile \
    'Seven_Coloured_Pencils_(rg-switch_sRGB).jpeg'

this will convert that image to sRGB, but then not write
the profile to the output image (verify with `Build/lagom/icc wow.png`).
It will look correct in image viewers, since they display PNGs without
an embedded color profile as sRGB.

(This works because 'Seven_Coloured_Pencils_(rg-switch_sRGB).jpeg'
contains a matrix profile, and Serenity's built-in sRGB profile
uses a matrix profile with a parametric curve.)
2023-05-03 15:05:13 +02:00
..
Filters LibGfx: Remove try_ prefix from bitmap creation functions 2023-01-26 20:24:37 +00:00
Font LibGfx: Prevent out-of-bounds accumulation in PathRasterizer 2023-04-19 06:05:10 +02:00
ICC ICC+image: Add conversion between color spaces for images :^) 2023-05-03 15:05:13 +02:00
ImageFormats LibGfx/JPEG: Factorize chunk size reading 2023-04-25 06:01:39 +02:00
AffineTransform.cpp LibGfx: Add AffineTransform::rotation() 2023-04-27 07:24:53 +02:00
AffineTransform.h LibGfx: Add AffineTransform::rotation() 2023-04-27 07:24:53 +02:00
AntiAliasingPainter.cpp LibGfx: Make all fill_path() code member functions and move into .cpp 2023-03-11 18:34:26 +00:00
AntiAliasingPainter.h LibGfx+LibWeb: Store radii as FloatSize rather than FloatPoint 2023-02-10 23:33:16 +01:00
Bitmap.cpp LibGfx: Move all image loaders and writers to a subdirectory 2023-03-21 22:39:25 +01:00
Bitmap.h LibGfx: Add Bitmap::begin() / Bitmap::end() 2023-04-05 13:24:00 +02:00
BitmapMixer.cpp LibGfx: Add BitmapMixer 2022-01-04 21:41:14 +02:00
BitmapMixer.h LibGfx: Add BitmapMixer 2022-01-04 21:41:14 +02:00
CharacterBitmap.h Libraries: Make CharacterBitmap instances at compile-time 2022-03-04 17:41:08 +01:00
CIELAB.h LibGfx: Move CIELAB to its own file 2023-04-30 05:57:20 +02:00
ClassicStylePainter.cpp LibGfx+Userland: Merge FrameShape and FrameShadow into FrameStyle 2023-04-30 05:49:46 +02:00
ClassicStylePainter.h LibGfx+Userland: Merge FrameShape and FrameShadow into FrameStyle 2023-04-30 05:49:46 +02:00
ClassicWindowTheme.cpp Userland: Use Font::pixel_size_rounded_up() in more places 2023-03-04 00:29:38 +01:00
ClassicWindowTheme.h LibGfx: Make ClassicWindowTheme menubar heights respect the font size 2023-01-03 15:25:02 +01:00
CMakeLists.txt LibGfx: Add DeltaE() function 2023-04-30 05:57:20 +02:00
Color.cpp LibGfx: Use StringView literals for CSS color list 2023-03-12 12:46:24 +00:00
Color.h LibGfx: Add ALWAYS_INLINE to Color::mixed_with()/interpolate() 2023-02-18 17:10:04 +01:00
CursorParams.cpp Meta+Userland: Pass Gfx::IntPoint by value 2022-12-07 11:48:27 +01:00
CursorParams.h Meta+Userland: Pass Gfx::IntPoint by value 2022-12-07 11:48:27 +01:00
DeltaE.cpp LibGfx: Add DeltaE() function 2023-04-30 05:57:20 +02:00
DeltaE.h LibGfx: Add DeltaE() function 2023-04-30 05:57:20 +02:00
DisjointRectSet.h LibGfx+Everywhere: Make DisjointRectSet work for non-int Rects 2022-10-27 13:06:33 +02:00
FillPathImplementation.cpp LibGfx: Floor draw origin in fill path implementation 2023-04-09 18:42:45 +02:00
Forward.h LibGfx: Add paint styles and allow gradients to be used as them 2023-01-22 18:15:52 +01:00
Gamma.h LibGfx: Remove a workaround for clang before 11 2022-10-04 23:35:07 +01:00
GradientPainting.cpp LibGfx: Add support to draw radial gradients with an rotation angle 2023-04-29 11:55:31 +01:00
Gradients.h LibWeb+LibGfx: Migrate (most of) the CSS gradient painting to LibGfx 2023-01-10 10:25:58 +01:00
GrayscaleBitmap.h LibGfx: Add a simple GrayscaleBitmap class 2023-03-23 08:27:51 +00:00
Line.h LibGfx: Add small convenience functions for Lines and AA Painter 2023-01-26 10:37:26 +00:00
Matrix.h LibGfx: Fix -Wdouble-promotion for float matrices 2023-05-02 17:15:48 +01:00
Matrix3x3.h LibGfx: Add Matrix3x3 2021-12-30 14:24:29 +01:00
Matrix4x4.h Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Orientation.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Painter.cpp LibGfx: Increase tolerance for bezier curves 2023-04-19 06:05:10 +02:00
Painter.h LibGfx: Add support to draw radial gradients with an rotation angle 2023-04-29 11:55:31 +01:00
PaintStyle.h LibGfx: Implement PaintStyle for SVG linear gradients 2023-04-28 09:42:28 +02:00
Palette.cpp LibGfx: Make the Palette constructor take NNRP<PaletteImpl> 2023-03-15 23:29:00 +01:00
Palette.h LibGfx: Make the Palette constructor take NNRP<PaletteImpl> 2023-03-15 23:29:00 +01:00
Path.cpp LibGfx: Transform the x axis rotation for elliptical arcs 2023-04-27 07:24:53 +02:00
Path.h Everywhere: Remove NonnullRefPtr.h includes 2023-03-06 23:46:35 +01:00
Point.cpp LibIPC+Everywhere: Change IPC::encode's return type to ErrorOr 2023-01-04 11:49:15 +01:00
Point.h LibGfx: Add Point::to_floored<T>() 2023-04-09 18:42:45 +02:00
Quad.h LibGfx: Add Gfx::Quad<T> to represent arbitrary quadrilaterals 2022-04-07 17:06:02 +02:00
Rect.cpp LibIPC+Everywhere: Change IPC::encode's return type to ErrorOr 2023-01-04 11:49:15 +01:00
Rect.h LibGfx: Add Rect::interpolated_to function 2023-04-13 20:18:49 +02:00
ShareableBitmap.cpp LibGfx: Remove try_ prefix from bitmap creation functions 2023-01-26 20:24:37 +00:00
ShareableBitmap.h LibIPC+Everywhere: Change IPC::encode's return type to ErrorOr 2023-01-04 11:49:15 +01:00
Size.cpp LibIPC+Everywhere: Change IPC::encode's return type to ErrorOr 2023-01-04 11:49:15 +01:00
Size.h LibIPC+Everywhere: Change IPC::encode's return type to ErrorOr 2023-01-04 11:49:15 +01:00
StandardCursor.h Base+WindowServer+LibGfx: Add new DragCopy Cursor 2022-08-31 17:29:44 +01:00
StylePainter.cpp LibGfx+Userland: Merge FrameShape and FrameShadow into FrameStyle 2023-04-30 05:49:46 +02:00
StylePainter.h LibGfx+Userland: Merge FrameShape and FrameShadow into FrameStyle 2023-04-30 05:49:46 +02:00
SystemTheme.cpp Everywhere: Support overriding the system color scheme 2023-03-10 22:03:49 +01:00
SystemTheme.h LibGfx: Return StringView for SystemTheme Roles 2023-04-30 05:48:14 +02:00
TextAlignment.h Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
TextAttributes.h LibGfx+Userland: Make TextAttributes::underline_style optional 2023-03-15 14:55:49 +01:00
TextDirection.cpp Everywhere: Fix a bunch of typos 2021-05-17 17:48:55 +01:00
TextDirection.h Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
TextElision.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
TextLayout.cpp LibGfx: Consider multi-code point glyphs when computing text width 2023-02-22 10:14:36 +01:00
TextLayout.h LibGfx: Make text painting better at aligning vector fonts vertically 2023-01-06 12:02:21 +01:00
TextWrapping.h Userland: Move text wrapping/elision into the new TextLayout :^) 2021-07-26 21:14:39 +04:30
Triangle.cpp Everywhere: Rename to_{string => deprecated_string}() where applicable 2022-12-06 08:54:33 +01:00
Triangle.h Everywhere: Rename to_{string => deprecated_string}() where applicable 2022-12-06 08:54:33 +01:00
Vector2.h Everywhere: Rename to_{string => deprecated_string}() where applicable 2022-12-06 08:54:33 +01:00
Vector3.h Everywhere: Rename to_{string => deprecated_string}() where applicable 2022-12-06 08:54:33 +01:00
Vector4.h Everywhere: Rename to_{string => deprecated_string}() where applicable 2022-12-06 08:54:33 +01:00
VectorN.h LibGfx: Remove unnecessary AK:: prefix in VectorN.h 2023-03-06 13:05:43 +00:00
WindowTheme.cpp Libraries: Use default constructors/destructors in LibGfx 2022-03-17 17:23:49 +00:00
WindowTheme.h LibGfx+LibGUI+WindowServer+Apps+Demos: Replace ToolWindows 2022-08-25 13:28:50 +02:00