Merge remote-tracking branch 'upstream/master'
commit
dec129bb29
|
@ -99,6 +99,20 @@ FUNCTION: void CGContextSetShouldSmoothFonts (
|
||||||
bool shouldSmoothFonts
|
bool shouldSmoothFonts
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
|
FUNCTION: void CGContextDrawImage (
|
||||||
|
CGContextRef c,
|
||||||
|
CGRect rect,
|
||||||
|
CGImageRef image
|
||||||
|
) ;
|
||||||
|
|
||||||
|
FUNCTION: size_t CGImageGetWidth (
|
||||||
|
CGImageRef image
|
||||||
|
) ;
|
||||||
|
|
||||||
|
FUNCTION: size_t CGImageGetHeight (
|
||||||
|
CGImageRef image
|
||||||
|
) ;
|
||||||
|
|
||||||
FUNCTION: void* CGBitmapContextGetData ( CGContextRef c ) ;
|
FUNCTION: void* CGBitmapContextGetData ( CGContextRef c ) ;
|
||||||
|
|
||||||
CONSTANT: kCGLRendererGenericFloatID HEX: 00020400
|
CONSTANT: kCGLRendererGenericFloatID HEX: 00020400
|
||||||
|
|
|
@ -76,6 +76,8 @@ STRUCT: CGAffineTransform
|
||||||
TYPEDEF: void* CGColorRef
|
TYPEDEF: void* CGColorRef
|
||||||
TYPEDEF: void* CGColorSpaceRef
|
TYPEDEF: void* CGColorSpaceRef
|
||||||
TYPEDEF: void* CGContextRef
|
TYPEDEF: void* CGContextRef
|
||||||
|
TYPEDEF: void* CGImageRef
|
||||||
|
|
||||||
TYPEDEF: uint CGBitmapInfo
|
TYPEDEF: uint CGBitmapInfo
|
||||||
|
|
||||||
TYPEDEF: int CGLError
|
TYPEDEF: int CGLError
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
! (c)2010 Joe Groff bsd license
|
! Copyright (C) 2010, 2011 Joe Groff, Slava Pestov.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien.data cocoa cocoa.classes cocoa.messages
|
USING: accessors alien.data cocoa cocoa.classes cocoa.messages
|
||||||
combinators core-foundation.data core-graphics.types fry images
|
combinators core-foundation.data core-graphics
|
||||||
images.loader io kernel math sequences ;
|
core-graphics.types fry locals images images.loader io kernel
|
||||||
|
math sequences ;
|
||||||
IN: images.cocoa
|
IN: images.cocoa
|
||||||
|
|
||||||
SINGLETON: ns-image
|
SINGLETON: ns-image
|
||||||
|
@ -44,23 +46,18 @@ ERROR: ns-image-planar-images-not-supported ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: load-image-rep ( -- image-rep )
|
: <CGImage> ( byte-array -- image-rep )
|
||||||
NSBitmapImageRep contents <CFData> -> autorelease -> imageRepWithData:
|
[ NSBitmapImageRep ] dip
|
||||||
NSColorSpace -> genericRGBColorSpace
|
<CFData> -> autorelease
|
||||||
NSColorRenderingIntentDefault
|
-> imageRepWithData:
|
||||||
-> bitmapImageRepByConvertingToColorSpace:renderingIntent: ;
|
-> CGImage ;
|
||||||
|
|
||||||
: image-rep>image ( image-rep -- image )
|
:: CGImage>image ( image -- image )
|
||||||
image new swap {
|
image CGImageGetWidth :> w
|
||||||
[ -> size CGSize>dim [ >integer ] map >>dim ]
|
image CGImageGetHeight :> h
|
||||||
[ -> bitmapData ]
|
{ w h } [
|
||||||
[ -> bytesPerPlane memory>byte-array >>bitmap ]
|
0 0 w h <CGRect> image CGContextDrawImage
|
||||||
} cleave
|
] make-bitmap-image ;
|
||||||
RGBA >>component-order
|
|
||||||
ubyte-components >>component-type
|
|
||||||
t >>premultiplied-alpha?
|
|
||||||
f >>upside-down? ;
|
|
||||||
|
|
||||||
M: ns-image stream>image
|
M: ns-image stream>image
|
||||||
drop
|
drop stream-contents <CGImage> CGImage>image ;
|
||||||
[ load-image-rep ] with-input-stream image-rep>image ;
|
|
||||||
|
|
Loading…
Reference in New Issue