Add PNG support for clipboard operations
- Implemented conditional compilation for image copy and retrieval functions in clipboard.cc, clipboard.h, and clipboard.mm, enabling PNG support when YAZE_LIB_PNG is defined. - Updated graphics_editor.cc and overworld_editor.cc to handle PNG data copying to the clipboard, including error handling for cases when PNG support is disabled. - Enhanced user feedback by providing alternative actions when PNG export is unavailable, improving overall user experience.
This commit is contained in:
@@ -6,9 +6,11 @@
|
||||
namespace yaze {
|
||||
namespace core {
|
||||
|
||||
#if YAZE_LIB_PNG == 1
|
||||
void CopyImageToClipboard(const std::vector<uint8_t>& data) {}
|
||||
void GetImageFromClipboard(std::vector<uint8_t>& data, int& width,
|
||||
int& height) {}
|
||||
#endif
|
||||
|
||||
} // namespace core
|
||||
} // namespace yaze
|
||||
@@ -7,8 +7,10 @@
|
||||
namespace yaze {
|
||||
namespace core {
|
||||
|
||||
#if YAZE_LIB_PNG == 1
|
||||
void CopyImageToClipboard(const std::vector<uint8_t> &data);
|
||||
void GetImageFromClipboard(std::vector<uint8_t> &data, int &width, int &height);
|
||||
#endif
|
||||
|
||||
} // namespace core
|
||||
} // namespace yaze
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#ifdef TARGET_OS_MAC
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#if YAZE_LIB_PNG == 1
|
||||
void yaze::core::CopyImageToClipboard(const std::vector<uint8_t>& pngData) {
|
||||
NSData* data = [NSData dataWithBytes:pngData.data() length:pngData.size()];
|
||||
NSImage* image = [[NSImage alloc] initWithData:data];
|
||||
@@ -41,5 +42,6 @@ void yaze::core::GetImageFromClipboard(std::vector<uint8_t>& pixel_data, int& wi
|
||||
CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgImage);
|
||||
CGContextRelease(context);
|
||||
}
|
||||
#endif // YAZE_LIB_PNG
|
||||
|
||||
#endif
|
||||
#endif // TARGET_OS_MAC
|
||||
|
||||
Reference in New Issue
Block a user