Add a unit test case checking that we don't crash any longer and still
read the image meta data correctly, even if not the image itself.
Also add another check for EOF and possibly invalid "bits" value in
another place where we were not checking for it when reading from the
stream.
Closes#23409.
Co-authored-by: PB <PBfordev@gmail.com>
Revert the change introduced in b473163da2
and restore the setting of the background of delta-RLE bitmaps to the
first entry in the colour table. This retains earlier wxWidgets
behaviour and matches Windows `LoadImage()` with `LR_CREATEDIBSECTION`.
Closes#23638.
Closes#23657.
This fixes several minor bugs in the loading of `BI_BITFIELDS` bitmaps,
related to handling different header sizes and the colour and alpha
masks.
Closes#23601.
Check that loading BMP files directly using wxDIB and via wxImage
built-in support for them produces the same result (which wasn't the
case for the RLE-compressed bitmaps until the last commit).
Calling Clear() wrongly modified any other wxImage objects reusing the
same data.
Fix this by adding the missing call to AllocExclusive() to this function
and also add a check for the image validity which was missing there as
well ever since this function was added back in fc3762b5fc (add
wxImage::Clear (patch by troelsk); closes#10141, 2009-01-09).
Also add a unit test.
Closes#23553.
This requires an image accessible via HTTP (and not HTTPS) but we don't
have any such working URLs any longer since the recent change on
www.wxwidgets.org.
Still make it possible to test this manually by predefining an
environment variable containing the URL.
Give more details in case of failure by using INFO() and use simple
CHECK()s instead of ugly WX_ASSERT_EQUAL_MESSAGE as they will show the
failing test anyhow.
No real changes.
Use a helper function to both make it shorter and provide more
information in case of a check failure: now the output will include the
name of the file, comparing with which failed, allowing to immediately
see which test failed.
This function doesn't exist in Catch2 any longer, so prepare for the
upgrade by stopping to use it and converting things to string more
explicitly.
No real changes yet.
This is a combination of running clang-tidy with modernize-use-nullptr
check for some ports (GTK, X11, OSX) and manual changes to the ports for
which it couldn't be used easily (MSW, DFB) and also manually updating
the docs.
Also replace NULL with null or nullptr in the comments as this is more
consistent with the use of nullptr in the code and makes it simpler to
grep for the remaining occurrences of NULL itself.
And also use null in the assert messages.
Only a few occurrences of "NULL" are still left in non-C files, mostly
corresponding to unclear comments or string output which it might not be
safe to change.
This port hasn't been updated for ages and is not used by anybody any
longer, so remove its code to facilitate maintenance.
Also remove references to this port from the documentation and most of
the other places (VMS-specific descrip.vms files still check for it
because it's not clear how to update them all), including configure.
Regenerate the latter and rebake all makefiles.
Finally document that this port is not available any longer.
This makes the code much more clear: LoadDib() now reads all the header
data while LoadBMPData() reads bitmap data only and doesn't read any
header values any more, unlike before.
It also allows not to have to pass neither bmpOffset nor IsBmp
parameters to LoadBMPData(), making its argument list much more
reasonable.
Finally, and, most importantly, it fixes loading bitmaps using
BI_BITFIELDS that was broken back in cccda9ef6b (Fix loading colour
palette from BMP file, 2019-12-28).
This commit also adds a unit test checking that this doesn't get broken
again without anyone noticing.
See #18634.
Closes#22499.
Don't use external image files, this makes it simpler to run the test
(it can be now done from any directory) and also experiment with it
(e.g. by making the test image fully transparent or fully opaque).
Remove the now unneeded .ico file but keep the .png one still used by
another test.
The name resolves to Cloudflare proxy which redirects all HTTP URLs to
HTTPS, which breaks the existing tests using HTTP, so prevent this from
happening by using the actual IP address instead.
Get rid of the ugly WX_ASSERT_MESSAGE() and also use REQUIRE/CATCH
directly instead of CppUnit compatibility macros.
Also use sections to execute the next loop iteration(s) even if the
current one fails.
This commit is best viewed ignoring whitespace-only changes.
- Fix handling of delta encoding that change vertical position
- Fix handling of end-of-line encodings that are given mid-line
- Removed unnecessary computation for linepos
Add regression tests for the bitmaps using RLE and loading which
previously didn't work correctly.
Closes https://github.com/wxWidgets/wxWidgets/pull/2590Closes#19318.
Stop throwing std::bad_alloc when BMP has large/negative biClrUsed by
checking that biClrUsed has a reasonable value before attempting to
allocate however much memory it indicates.
Add unit tests showing the loading such invalid bitmaps now correctly
returns an error rather than throwing an exception.
Closes https://github.com/wxWidgets/wxWidgets/pull/2583Closes#19295.
Use wxUIntPtr rather than (unsigned) long in wxImage::ResampleNearest()
as long is still 32 bits under Win64 and so doesn't allow the code there
to work with images larger than 2^16 in either direction, when it could
be allowed in this case.
Document the current limits on the size of the image and add a unit test
checking that resizing images of size greater than 2^16 works in 64 bits.
See #18550.
Add more functions for manipulating wxImage colours.
Show using them in the same and add new unit tests for them.
This is a squashed commit of branch 'tomay3000/image-lightness'.
Closes https://github.com/wxWidgets/wxWidgets/pull/2310
This just uses the existing wxImage ctor from XPM data and wxCursor ctor
from wxImage, but will allow the code creating cursors from XPM to still
work even when wxImage ctor from XPM is made explicit.
Add a trivial test just to check that the new ctor can be used.
When doing an RGB->HSV->RGB roundtrip, the original value should be
restored (HSV, being double, has sufficient precision).
For e.g. `RGBValue(1,2,3)`, the equivalent resulting code for blue is
`trunc(int * 255.0 / 255.0)` (cast from double to int truncates).
At least with x87 FP math and its immediate 80bit extended precision
the resulting value is ~trunc(2.9999..), i.e. 2, similar problems may
exist on other architectures with other values.
Using proper rounding avoids the error magnification.
Closes https://github.com/wxWidgets/wxWidgets/pull/2078
Check for the presence of alpha channel before using it in the fallback
code.
Also add a unit test exercising this branch of the code and which
crashed before.
No real changes, just execute only the tests relevant for the section
being executed instead of always running the code loading PNG images
when running a section not using them at all.
This has the advantages of being a bit faster to execute (and the total
test suite run time does add up) and, more importantly, showing the
right amount of tests when executing a single section: e.g. now it's 1
in the simplest case, as expected, and not 5.
The disadvantage is, of course, slightly more code duplication, but it
doesn't seem a huge problem in practice and making each section code
more self-contained is arguably worth it.
Also, compensate for this somewhat by extracting all XPM definitions at
the function level: those are only initialized once (being static), so
there is no need to duplicate them.
Finally, also call AddHandler() once instead of once per section as
before.
Fix a bug with wrong size passed to memset() introduced in 1f0ade29f0
(Fix using mask colour even if there is no mask in wxImage::Paste,
2020-09-30) which caused memory corruption and add a test (the one with
the large negative vertical offset) allowing to reproduce this reliably.
Closes https://github.com/wxWidgets/wxWidgets/pull/2067
In case an image without alpha is pasted on top of an image with alpha,
the alpha blending gives wrong results. This is caused by the fact that
the final (if nothing has been pasted yet) pixel copying algorithm in
Paste() does not take into account whether the pasted image actually
uses a mask.
To fix this:
- Add the check for image.HasMask().
- In case there is no mask, simply copy the image via memcpy.
- Finally, update the alpha channel of the changed image (if present):
whenever a pixel is copied, the alpha is set to fully opaque.
Closes https://github.com/wxWidgets/wxWidgets/pull/2065