Commit Graph

109 Commits

Author SHA1 Message Date
Vadim Zeitlin
2574b9172e Rename wxBitmap::GetImage() to OSXGetImage()
Make it more clear that this function is specific to Mac ports.
2021-09-03 21:32:52 +02:00
Vadim Zeitlin
ff4cd70412 Avoid crash in wxBitmap::GetImage() for invalid bitmaps
Just return NULL from this (wxOSX private, in spite of not using a
port-specific prefix) method.

This fixes crash in wxButton::SetBitmapXXX(wxNullBitmap), as shown by
the new test case which used to crash but doesn't do it any longer.

Closes #19257.
2021-09-03 00:28:58 +02:00
Igor Korot
9394d26c40 Implement wxBitmap(const wxCursor&) constructor for OSX 2021-04-10 14:17:27 +02:00
Vadim Zeitlin
d89d3b6851 Remove harmless unused variables warnings in non-debug build
Suppress a few -Wunused-variable and -Wunused-parameter warnings when
using --disable-debug.
2021-02-14 12:43:30 +01:00
Artur Wieczorek
e74cc53775 Fix creating CGImage from wxBitmap
For internal purposes wxBitmap with mask should be converted to CGImage
with alpha values only (with no mask). This is i.a. needed to assure
compatibility of wxGraphicsBitmap format with other ports where these
bitmaps are in pure ARGB format.
2021-02-08 18:56:10 +01:00
Artur Wieczorek
4590f28f7e Fix converting wxBitmap with alpha and mask to wxImage (wxOSX)
When pixel is not masked it should be stored in the target wxImage
in non-premultiplied format.
2021-01-20 19:37:12 +01:00
Artur Wieczorek
79be42122f Don't convert mask to alpha values while converting wxImage to wxBitmap (wxOSX)
wxImage with mask should be converted to wxBitmap with mask and not to
wxBitmap with alpha channel values. Converting wxImage mask to wxBitmap
alpha is not implemented under wxMSW and wxGTK and wxOSX implementation
should adhere to this convention.
2021-01-18 22:29:40 +01:00
Stefan Csomor
f8af2601c2 Add wxOSX_VERIFY_NOERR macro and use it in wxOSX code
This macro replaces the deprecated __Verify_noErr defined in the SDK.

It is different from assert, as the expression given to the macro is
always evaluated and then, if the result is not zero, and asserts are
on, an assert containing a human readable message with the description
of the error code is triggered.

Closes https://github.com/wxWidgets/wxWidgets/pull/1973

Co-authored-by: Vadim Zeitlin <vadim@wxwidgets.org>
2021-01-17 23:57:38 +01:00
Stefan Csomor
458d4666df Fix wxBundleResourceHandler::LoadFile() return value
Return true in case of success instead of always returning false.
2021-01-16 22:18:43 +01:00
Artur Wieczorek
9bbaab6e56 Fix converting wxBitmap to wxImage
wxBitmap can have both alpha channel and a mask so alpha channel values
should be passed to the target wxImage even if mask exists.

Closes #19010.
2020-12-14 20:06:35 +01:00
Stefan Csomor
1cda310bbf Attempt at a All-In-One implementation 2020-10-16 18:17:35 +02:00
Robin Dunn
097008833e Use the original image to check for a mask, not the one that may have had the mask converted to alpha 2020-10-14 17:42:51 -07:00
Stefan Csomor
818f8fe1d6 macOS: fixing wxImage generation from wxBitmap
after 992b594c15 the byte value for ‚masked‘ changed, adapt this accordingly, see https://trac.wxwidgets.org/ticket/18775
2020-07-20 11:05:17 +02:00
Stefan Csomor
9f89467ff1 Support arbitrary scale factors, not just 2, when loading bitmaps
This notably enables support for @3x icons used under iOS.

Closes https://github.com/wxWidgets/wxWidgets/pull/1983
2020-07-18 19:44:43 +02:00
Vadim Zeitlin
25e256a0f5 Merge branch 'osx_icns_imagehandler' of https://github.com/TcT2k/wxWidgets
Add handler for ICNS files (wxBITMAP_TYPE_ICON).

Also remove some old unused Carbon files.

See https://github.com/wxWidgets/wxWidgets/pull/1716

Closes #18647.
2020-02-04 02:26:42 +01:00
Paul Cornett
948ddc6e0f Eliminate -Wcast-qual warnings with GCC and Clang
Use const_cast, mutable, and various other changes to avoid -Wcast-qual
2020-02-02 22:50:32 -08:00
Tobias Taschner
7a729e8a85 Add handler for ICNS files (wxBITMAP_TYPE_ICON)
After some recent changes bitmaps and icons with the type
wxBITMAP_TYPE_ICON could no longer be loaded. This implements a handler
for this (macOS only) bitmap type like the handler for
wxBITMAP_TYPE_ICON_RESOURCE.
2020-01-23 14:44:59 +01:00
Artur Wieczorek
7143ff46b0 Ensure bitmap image exists while querying for a row stride
Obtaining bytes per row makes sense only for bitmap image representation
so we have to ensure that the bitmap represenation exists before querying
for its row stride length. NSImage per se cannot provide this information.

Closes #18606.
2019-12-01 22:58:18 +01:00
Artur Wieczorek
a1cc2056bc Update NSImage with changes made to bitmap pixel data
In order to get access to wxBitmap's pixel data we actually have to work
with CGBitmapContext data and this context is created from NSImage by call
to wxBitmapRefData::EnsureBitmapExists() when we prepare to get access
to the data in wxBitmapRefData::GetRawAccess().
So, when we finish updating bitmap data we should update original NSImage
with actual CGBitmapContext data in wxBitmapRefData::EndRawAccess().

See #18606.
2019-12-01 22:39:38 +01:00
Stefan Csomor
715cb66ac4 Fixing IconRef Build re adding support for reading icns files 2019-11-05 09:46:02 +01:00
Olly Betts
e2b4cd9f77 Fix typos in comments and assertion messages
Closes https://github.com/wxWidgets/wxWidgets/pull/1596
2019-10-08 23:30:22 +02:00
Artur Wieczorek
244547a010 Return Boolean value as declared 2019-10-01 00:21:20 +02:00
Artur Wieczorek
d0311cec8d Move reused code to the separate function
Checking whether alpha info flag contains one of
the constants representing image/bitmap with alpha
channel is done more than once in the code so this
check can be moved to a dedicated function.
2019-10-01 00:21:01 +02:00
Artur Wieczorek
01b769e975 Don't use m_ prefix in the names of non-member variables
Using "m_" prefix for non-member variables is against
the naming convention and hence is misleading.
2019-10-01 00:20:43 +02:00
Artur Wieczorek
3c0dbc17de Guard functions with wxCHECK macros rather than wxASSERT
If bitmap context was not created successfully
the function execution should be terminated.
2019-10-01 00:20:15 +02:00
Artur Wieczorek
2bba863937 Get rid of unnecessary variables
We can pass NULL argument directly to CGBitmapContextCreate()
and using a temporary variable holding NULL is not necessary.
2019-10-01 00:19:51 +02:00
Artur Wieczorek
b21f9ff6f5 Fix getting a sub-bitmap of wxBitmap with alpha channel and mask
Since wxBitmap can have both alpha channel values and mask we have to use
alpha channel (if required) in the sub-bitmap even if the mask is provided
too.

See #18513.
2019-09-29 16:28:12 +02:00
Artur Wieczorek
93f1384f7e Don't use m_ prefix in the names of non-member variables
Using "m_" prefix for non-member variables is not in line with the naming
convention and hence is misleading.
2019-09-29 16:23:12 +02:00
Artur Wieczorek
ac9c4d06e2 Fix creating wxMask image from raw data
In the function wxMask::OSXCreate() to create a mask image, data copying
from the supplied memory buffer was not actually implemented and therefore
created mask was invalid.

Closes #18513.
2019-09-29 16:21:45 +02:00
Artur Wieczorek
0818e334fd Fix making a copy of wxBitmap
Because wxBitmap can have both alpha channel and mask, so the presence of the mask shouldn't prevent alpha channel from being enabled (if necessary).
2019-09-16 20:32:28 +02:00
Artur Wieczorek
992b594c15 Fix creating CGImage from bitmap data
Alpha channel values of created CGImage should be
a superposition of the actual alpha channel values
and bitmap mask (if exists).

See #18498.
2019-09-16 20:31:35 +02:00
Artur Wieczorek
a7cc686853 Initialize flag with actual value
There is no need to pre-initialize alpha flag with default value.
2019-09-06 00:15:38 +02:00
Artur Wieczorek
f5a589180f Fix converting wxImage with mask to wxBitmap with alpha channel
For wxImage having both mask and alpha channel (it is technically possible), mask cannot be converted to alpha values and in this case resulting wxBitmap will also have both mask and alpha channel.
2019-09-06 00:15:23 +02:00
Artur Wieczorek
991f11707f Convert wxImage with mask to wxBitmap with alpha channel
Since we always convert wxImage to 32 bpp wxBitmap, there is no reason to keep a separate mask for wxBitmap because alpha channel can be used directly.
2019-09-01 11:01:38 +02:00
Artur Wieczorek
8403b79ad7 Fix colours of mask bitmap
Monochrome mask bitmap should have white pixels in the unmasked area and black pixels in the masked area, quite the opposite to what is implemented now.

Closes #10098.
2019-08-30 00:03:37 +02:00
Artur Wieczorek
0522587bcb Fix creating a bitmap representing wxMask
When bitmap data are accessed with wxNativePixelData, which is designed
to handle RGB bitmaps, Alpha() function cannot be used because in this
case alpha component index is set to the default value -1 and actually
the blue component of the "preceding" pixel is accessed.

Closes #18478.
2019-08-29 18:35:14 +02:00
Paul Cornett
9511ab08f1 More use of wxOVERRIDE 2019-04-05 11:08:53 -07:00
Paul Cornett
fe1737d399 Reduce the scope of some local variables 2019-04-05 10:44:02 -07:00
Stefan Csomor
cfded96627 fixing truncation error in GetSubBitmap
fixes #18362
2019-03-17 12:19:53 +01:00
VZ
cce9ef9d53 Fix compatibility breakage with wxMask::Create() in wxOSX (#1019)
Defining a Mac-specific Create(wxMemoryBuffer) overload hid the other
Create() overloads, which are actually part of the public API, so they
couldn't be used any longer since the changes of
e7d21f6638

Fix this by renaming this Create() to OSXCreate(), to avoid hiding the
base class methods.

Also remove Mac-specific ctor taking wxMemoryBuffer, this is confusing
and can be avoided by just calling OSXCreate() directly in the only
place where it is used.
2018-11-09 17:52:58 +01:00
Stefan Csomor
a69a43bc53 fixing warning for unused param 2018-10-22 16:27:22 +02:00
Stefan Csomor
162ea7b1ef bringing back old style macOS icons loading
see https://github.com/wxWidgets/wxWidgets/pull/925
2018-10-05 15:01:24 +02:00
Stefan Csomor
9bfa4c6da3 further cleanup 2018-09-24 00:12:33 +02:00
Stefan Csomor
f29faa0217 optimize handling of high-res native images 2018-09-24 00:12:33 +02:00
Stefan Csomor
266f32493e Removing non-native bitmap code, using common code for iOS and macOS 2018-09-24 00:11:31 +02:00
Stefan Csomor
34716b18a6 new ICNS Handler 2018-09-24 00:11:31 +02:00
Stefan Csomor
ee8132fea9 using NSImage as first-class native representation
If given an NSImage this will be used, unless raw bitmap data access is needed, lazily converting to a CGBitmapContext at that moment
2018-09-24 00:11:31 +02:00
Stefan Csomor
84f68aa764 Fixes and Cleanup 2018-09-24 00:11:31 +02:00
Stefan Csomor
e7d21f6638 Initial Commit of full native bitmap macOS implementation
Right now, to better test regressions, with dual implementation
2018-09-24 00:11:31 +02:00
Stefan Csomor
87e9b3963e Fixing creation from CGContextRef
Our native buffer must be updated as well, otherwise RawAccess will fail
2018-09-24 00:11:31 +02:00