History log of /haiku/src/kits/interface/ColorConversion.cpp
Revision Date Author Comments
# d1035d48 16-Nov-2021 Augustin Cavalier <waddlesplash@gmail.com>

ColorConversion: Add cast to silence -Wclass-memaccess.


# bb187c91 15-Sep-2021 Jérôme Duval <jerome.duval@gmail.com>

interface: add colorspaces support for RGB48 and RGBA64

these colorspaces are packed as RGB or RGBA, not BGR or BGRA.
RGB48_BIG and RGBA64 only differ in the endianess of the channel the 2-byte value.

this is a big difference with RGB24_BIG and RGBA32_BIG, in which case _BIG
means the order is RGB (BGR) and not BGR (BGRA).
BGR48, BGRA64 could indeed be added, if needed.

I chose 0x11 and 0x12 arbitrarily, but given the order of channels 0x1011
and 0x1012 might make more sense. This would mean using another bit for "real"
bigendian colorspaces.

Only the color conversion to 32-bits is implemented.

Tested with the RAWTranslator modified to output 16bpp with success.

Found some references in enum AVPixelFormat in libavutil/pixfmt.h.

Change-Id: I4b023dec85d01f1e63e1b053139e5bb5d263a0e0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4468
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# f1fafe31 12-Apr-2019 Augustin Cavalier <waddlesplash@gmail.com>

kernel/OS.h: Include sys/types.h instead of pthread.h.

This avoids polluting the namespace significantly. Also adjust
all files which depended on this behavior to include pthread.h
directly.


# e89985cc 10-Feb-2019 Adrien Destugues <pulkomandy@pulkomandy.tk>

Fix drawing of B_GRAY1 bitmaps.

- Colors were reversed
- Padding was not handled properly because of a roundeing error

Add a test that shows the issue (behavior confirmed against BeOS)

Change-Id: I4c6e954fb6bdab92ad4e0e96897e78b26eb4727b
Reviewed-on: https://review.haiku-os.org/c/1025
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# 4089701d 09-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

interface: Remove some unreachable "break"s.

Spotted by Clang.


# 59d0c2e4 30-Apr-2010 Stephan Aßmus <superstippi@gmx.de>

* Introduced PaletteConverter::IndexForRGBA32() which checks if the alpha
component of a 32 bit color is below 128 and returns the special CMAP8 index
for indicating transparency.
* Changed the WriteCMAP() color conversion function to expext a 32bit RGBA
value and use IndexForRGBA32().
* Adapted B_CMAP8 target color space case of ConvertBits() to the new
semantics.

This allows transparency in bitmaps when converting B_RGBA32 bitmaps to
B_CMAP8, tested only for this case and working as expected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36549 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 015943d7 30-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Use pthread_once() to guard the initialization of sPaletteConverter. This
changes the semantics slightly: Previously after a failed initialization
another invocation of InitializeDefault() could theoretically initialize the
converter. Since the only error conditions are out of memory and broken app
server connection, this shouldn't really matter, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34383 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3572efc2 01-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Should fix bug #3401. Put the parenthesis at the wrong spot resulting in wrong offsets.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29125 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6eb09230 01-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Resolve further warnings on GCC4.
* Enable -Werror on GCC4 builds as well (limited to the same selected targets).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29118 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 37b83b1a 22-Oct-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

The system palette was defined in two files. Moved to a private header,
included by the two.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22660 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fc6a714e 11-Oct-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Static variables should have the s prefix.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22509 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 65e63b98 11-Oct-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

PaletteConverter now exports a static InitializeDefault() method, which
can be used (and is, by _init_interface_kit()) to initialize the ...
er... default instance of
PaletteConverter using the system color map, thus avoid building the
list of colors, which takes some time. Fixes bug #505.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22508 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ad4c6c1 26-Dec-2006 Michael Lotz <mmlr@mlotz.ch>

ConvertBits() now checks the out of range case before reading/writing the buffers. Previously it was possible to read/write one line after the buffers end because the values were not checked after line advancement. This fixes the crashing bug #850. It however reveals another bug that brings the app_server into an endless loop when using the TextFader screensaver.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19626 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0354c3c2 01-Aug-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added missing return statement

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18326 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0bc48fb 19-May-2006 Axel Dörfler <axeld@pinc-software.de>

Some more GCC 4 and PPC fixes.
* Mesa doesn't compile yet, as some PPC specific stuff seems to be
missing, Philippe?
* Cortex and some other stuff has been marked x86-only, although
it's more of a "GCC 2.95.3"-only.
* I'm not sure if it's a bug in GCC 4, or if that's what the C
standard demands, but sizeof(some_type::some_field) is not
valid anymore :-/


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17515 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0ce9ba6b 15-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* BPrivate::ConvertBits() did not take the source or destination bits length
into account when copying to the same color space (new code isn't that fast,
but it works).
* BBitmap::ImportBits() did not take the specified offset into account at all.
This fixes bug #313.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16812 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0581480c 13-Mar-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed ServerBitmap::ImportBits() to use the correct width/height
* Extended ConvertBits() to properly handle negative offsets and overlapping lines
* Implemented blitting the software cursor to the bitmap returned from ReadBitmap()

Note: In the future we will have to directly use the final graphics buffer for ReadBitmap() if we want DirectWindow output too (R5 includes it). I don't know how R5 handles the hardware cursor though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16766 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bdc6f9e7 05-Mar-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed a swapping bug for 16 bit colorspaces
* Added some comments
* Added some checking to avoid noop shifts
* Added buffer length checks
* Implemented (as Stephan suggested) a version of ConvertBits() that takes offsets.
This new version allows to move a region of the source into a region (possibly not at the same point) on the dest while converting colorspaces on the fly.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16592 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b09e53fa 04-Mar-2006 Michael Lotz <mmlr@mlotz.ch>

Wrote a new color conversion engine. It's 2-5 times faster than the old one (depending on colorspaces) and about half in size.
I've put it into ColorConversion.cpp and moved PaletteConverter there too, cleaning up Bitmap.cpp.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16580 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 59d0c2e45e612140ff9a9b82ed56e02499eefe66 30-Apr-2010 Stephan Aßmus <superstippi@gmx.de>

* Introduced PaletteConverter::IndexForRGBA32() which checks if the alpha
component of a 32 bit color is below 128 and returns the special CMAP8 index
for indicating transparency.
* Changed the WriteCMAP() color conversion function to expext a 32bit RGBA
value and use IndexForRGBA32().
* Adapted B_CMAP8 target color space case of ConvertBits() to the new
semantics.

This allows transparency in bitmaps when converting B_RGBA32 bitmaps to
B_CMAP8, tested only for this case and working as expected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36549 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 015943d78f29e326cf9d120ea52b3badab627775 30-Nov-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Use pthread_once() to guard the initialization of sPaletteConverter. This
changes the semantics slightly: Previously after a failed initialization
another invocation of InitializeDefault() could theoretically initialize the
converter. Since the only error conditions are out of memory and broken app
server connection, this shouldn't really matter, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34383 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3572efc23974d8404c31e3eace4470ae68a7ec8b 01-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

Should fix bug #3401. Put the parenthesis at the wrong spot resulting in wrong offsets.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29125 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6eb09230bae52bcdf045e1f1920b67205c29adc8 01-Feb-2009 Michael Lotz <mmlr@mlotz.ch>

* Resolve further warnings on GCC4.
* Enable -Werror on GCC4 builds as well (limited to the same selected targets).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29118 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 37b83b1a2d32b92cb6e11a18ace276039b90bd2a 22-Oct-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

The system palette was defined in two files. Moved to a private header,
included by the two.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22660 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fc6a714ec0834d7526dfdb0f4ea5c4a399bbe53c 11-Oct-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Static variables should have the s prefix.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22509 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 65e63b987dda42a7492b7f8eb68b4f71bd8134cc 11-Oct-2007 Stefano Ceccherini <stefano.ceccherini@gmail.com>

PaletteConverter now exports a static InitializeDefault() method, which
can be used (and is, by _init_interface_kit()) to initialize the ...
er... default instance of
PaletteConverter using the system color map, thus avoid building the
list of colors, which takes some time. Fixes bug #505.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22508 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ad4c6c1b8cff539aa22f09584358130dfef4630 26-Dec-2006 Michael Lotz <mmlr@mlotz.ch>

ConvertBits() now checks the out of range case before reading/writing the buffers. Previously it was possible to read/write one line after the buffers end because the values were not checked after line advancement. This fixes the crashing bug #850. It however reveals another bug that brings the app_server into an endless loop when using the TextFader screensaver.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19626 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0354c3c2d5d044694513311205daecee3f957cc9 01-Aug-2006 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added missing return statement

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18326 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b0bc48fbd360f10cee1856e03393c63dcbdd180f 19-May-2006 Axel Dörfler <axeld@pinc-software.de>

Some more GCC 4 and PPC fixes.
* Mesa doesn't compile yet, as some PPC specific stuff seems to be
missing, Philippe?
* Cortex and some other stuff has been marked x86-only, although
it's more of a "GCC 2.95.3"-only.
* I'm not sure if it's a bug in GCC 4, or if that's what the C
standard demands, but sizeof(some_type::some_field) is not
valid anymore :-/


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17515 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0ce9ba6ba32a6e28971899c78b83ae4c63b231fb 15-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* BPrivate::ConvertBits() did not take the source or destination bits length
into account when copying to the same color space (new code isn't that fast,
but it works).
* BBitmap::ImportBits() did not take the specified offset into account at all.
This fixes bug #313.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16812 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0581480cfec831197846c0449f838768412e2e03 13-Mar-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed ServerBitmap::ImportBits() to use the correct width/height
* Extended ConvertBits() to properly handle negative offsets and overlapping lines
* Implemented blitting the software cursor to the bitmap returned from ReadBitmap()

Note: In the future we will have to directly use the final graphics buffer for ReadBitmap() if we want DirectWindow output too (R5 includes it). I don't know how R5 handles the hardware cursor though.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16766 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bdc6f9e7ef0a4ef9c8f729c2979af0c0207fd007 05-Mar-2006 Michael Lotz <mmlr@mlotz.ch>

* Fixed a swapping bug for 16 bit colorspaces
* Added some comments
* Added some checking to avoid noop shifts
* Added buffer length checks
* Implemented (as Stephan suggested) a version of ConvertBits() that takes offsets.
This new version allows to move a region of the source into a region (possibly not at the same point) on the dest while converting colorspaces on the fly.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16592 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b09e53fae0c50ed31994c3f03d477ae2af8ab951 04-Mar-2006 Michael Lotz <mmlr@mlotz.ch>

Wrote a new color conversion engine. It's 2-5 times faster than the old one (depending on colorspaces) and about half in size.
I've put it into ColorConversion.cpp and moved PaletteConverter there too, cleaning up Bitmap.cpp.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16580 a95241bf-73f2-0310-859d-f6bbb57e9c96