@@ -8,6 +8,7 @@ use objc2::{define_class, msg_send, AllocAnyThread, DefinedClass, MainThreadMark
88use objc2_core_foundation:: { CFRetained , CGPoint } ;
99use objc2_core_graphics:: {
1010 CGBitmapInfo , CGColorRenderingIntent , CGColorSpace , CGDataProvider , CGImage , CGImageAlphaInfo ,
11+ CGImageByteOrderInfo , CGImageComponentInfo , CGImagePixelFormatInfo ,
1112} ;
1213use objc2_foundation:: {
1314 ns_string, NSDictionary , NSKeyValueChangeKey , NSKeyValueChangeNewKey ,
@@ -223,7 +224,7 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for CGImpl<
223224 layer. setContentsGravity ( unsafe { kCAGravityTopLeft } ) ;
224225
225226 // Initialize color space here, to reduce work later on.
226- let color_space = unsafe { CGColorSpace :: new_device_rgb ( ) } . unwrap ( ) ;
227+ let color_space = CGColorSpace :: new_device_rgb ( ) . unwrap ( ) ;
227228
228229 // Grab initial width and height from the layer (whose properties have just been initialized
229230 // by the observer using `NSKeyValueObservingOptionInitial`).
@@ -308,6 +309,17 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'_,
308309 }
309310 } ;
310311
312+ // `CGBitmapInfo` consists of a combination of `CGImageAlphaInfo`, `CGImageComponentInfo`
313+ // `CGImageByteOrderInfo` and `CGImagePixelFormatInfo` (see e.g. `CGBitmapInfoMake`).
314+ //
315+ // TODO: Use `CGBitmapInfo::new` once the next version of objc2-core-graphics is released.
316+ let bitmap_info = CGBitmapInfo (
317+ CGImageAlphaInfo :: NoneSkipFirst . 0
318+ | CGImageComponentInfo :: Integer . 0
319+ | CGImageByteOrderInfo :: Order32Little . 0
320+ | CGImagePixelFormatInfo :: Packed . 0 ,
321+ ) ;
322+
311323 let image = unsafe {
312324 CGImage :: new (
313325 self . imp . width ,
@@ -316,8 +328,7 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'_,
316328 32 ,
317329 self . imp . width * 4 ,
318330 Some ( & self . imp . color_space ) ,
319- // TODO: This looks incorrect!
320- CGBitmapInfo :: ByteOrder32Little | CGBitmapInfo ( CGImageAlphaInfo :: NoneSkipFirst . 0 ) ,
331+ bitmap_info,
321332 Some ( & data_provider) ,
322333 ptr:: null ( ) ,
323334 false ,
0 commit comments