Okay, decided on something for images. Let's try this.
This commit is contained in:
parent
7995a4460c
commit
165b3a8a51
|
@ -21,6 +21,7 @@ list(APPEND _LIBUI_SOURCES
|
|||
darwin/form.m
|
||||
darwin/grid.m
|
||||
darwin/group.m
|
||||
darwin/image.m
|
||||
darwin/label.m
|
||||
darwin/main.m
|
||||
darwin/map.m
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
// 25 june 2016
|
||||
#import "uipriv_darwin.h"
|
||||
|
||||
struct uiImage {
|
||||
NSImage *i;
|
||||
NSSize size;
|
||||
};
|
||||
|
||||
uiImage *uiNewImage(double width, double height)
|
||||
{
|
||||
uiImage *i;
|
||||
|
||||
i = uiNew(uiImage);
|
||||
i->size = NSMakeSize(width, height);
|
||||
i->i = [[NSImage alloc] initWithSize:i->size];
|
||||
return i;
|
||||
}
|
||||
|
||||
void uiFreeImage(uiImage *i)
|
||||
{
|
||||
[i->i release];
|
||||
uiFree(i);
|
||||
}
|
||||
|
||||
void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, int pixelStride)
|
||||
{
|
||||
NSBitmapImageRep *repCalibrated, *repsRGB;
|
||||
char *pix[1];
|
||||
|
||||
pix[0] = (char *) pixels;
|
||||
repCalibrated = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:pix
|
||||
pixelsWide:pixelWidth
|
||||
pixelsHigh:pixelHeight
|
||||
bitsPerSample:8
|
||||
samplesPerPixel:4
|
||||
hasAlpha:YES
|
||||
isPlanar:NO
|
||||
colorSpaceName:NSCalibratedRGBColorSpace
|
||||
bitmapFormat:0
|
||||
bytesPerRow:pixelStride
|
||||
bitsPerPixel:32];
|
||||
repsRGB = [repCalibrated bitmapImageRepByRetaggingWithColorSpace:[NSColorSpace sRGBColorSpace]];
|
||||
[repCalibrated release];
|
||||
|
||||
[i->i addRepresentation:repsRGB];
|
||||
[repsRGB setSize:i->size];
|
||||
[repsRGB release];
|
||||
}
|
|
@ -1,6 +1,12 @@
|
|||
// 20 june 2016
|
||||
// kept in a separate file for now
|
||||
|
||||
typedef struct uiImage uiImage;
|
||||
|
||||
_UI_EXTERN uiImage *uiNewImage(double width, double height);
|
||||
_UI_EXTERN void uiFreeImage(uiImage *i);
|
||||
_UI_EXTERN void uiImageAppend(uiImage *i, void *pixels, int pixelWidth, int pixelHeight, int pixelStride);
|
||||
|
||||
typedef struct uiTableModel uiTableModel;
|
||||
typedef struct uiTableModelHandler uiTableModelHandler;
|
||||
|
||||
|
|
Loading…
Reference in New Issue