From 640bc7546d4d8ad5228e09ed2d280ea12b0690e9 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 25 Jun 2011 07:58:03 +1000 Subject: Initial implementation of RGBA images. --- cocoa/PlatCocoa.h | 1 + cocoa/PlatCocoa.mm | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ cocoa/ScintillaCocoa.h | 1 + 3 files changed, 90 insertions(+) (limited to 'cocoa') diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h index 0653bc728..0e3c5f2e2 100644 --- a/cocoa/PlatCocoa.h +++ b/cocoa/PlatCocoa.h @@ -93,6 +93,7 @@ public: void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back); void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int flags); + void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage); void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back); void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource); void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 9397e9fbd..1e81fb6e1 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -639,6 +639,73 @@ void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, int /*cornerSize*/, C } } +static CGImageRef ImageFromRGBA(int width, int height, const unsigned char *pixelsImage, bool invert) { + CGImageRef image = 0; + + // Create an RGB color space. + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + if (colorSpace) { + const int bitmapBytesPerRow = ((int) width * 4); + const int bitmapByteCount = (bitmapBytesPerRow * (int) height); + + // Create a data provider. + CGDataProviderRef dataProvider = 0; + unsigned char *pixelsUpsideDown = 0; + if (invert) { + pixelsUpsideDown = new unsigned char[bitmapByteCount]; + + for (int y=0; ysecond release]; + it->second = img; + } +} + void ListBoxImpl::ClearRegisteredImages() { for (ImageMap::iterator it=images.begin(); diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h index b24938d05..80a483b06 100644 --- a/cocoa/ScintillaCocoa.h +++ b/cocoa/ScintillaCocoa.h @@ -20,6 +20,7 @@ #include #include +#include #include "ILexer.h" -- cgit v1.2.3