@@ -190,20 +190,23 @@ UINT32 shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors)
190190 * Caller should free the andMaskData and xorMaskData later.
191191 */
192192int shadow_subsystem_pointer_convert_alpha_pointer_data (
193- BYTE * pixels , BOOL premultiplied , UINT32 width , UINT32 height ,
193+ const BYTE * WINPR_RESTRICT pixels , BOOL premultiplied , UINT32 width , UINT32 height ,
194+ SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE * WINPR_RESTRICT pointerColor )
195+ {
196+ return shadow_subsystem_pointer_convert_alpha_pointer_data_to_format (
197+ pixels , PIXEL_FORMAT_BGRX32 , premultiplied , width , height , pointerColor );
198+ }
199+
200+ int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format (
201+ const BYTE * pixels , UINT32 format , BOOL premultiplied , UINT32 width , UINT32 height ,
194202 SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE * pointerColor )
195203{
196- BYTE * pSrc8 = NULL ;
197- BYTE * pDst8 = NULL ;
198204 UINT32 xorStep = 0 ;
199205 UINT32 andStep = 0 ;
200206 UINT32 andBit = 0 ;
201207 BYTE * andBits = NULL ;
202208 UINT32 andPixel = 0 ;
203- BYTE A = 0 ;
204- BYTE R = 0 ;
205- BYTE G = 0 ;
206- BYTE B = 0 ;
209+ const size_t bpp = FreeRDPGetBytesPerPixel (format );
207210
208211 xorStep = (width * 3 );
209212 xorStep += (xorStep % 2 );
@@ -227,20 +230,23 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data(
227230 return -1 ;
228231 }
229232
230- for (UINT32 y = 0 ; y < height ; y ++ )
233+ for (size_t y = 0 ; y < height ; y ++ )
231234 {
232- pSrc8 = & pixels [(width * 4 ) * (height - 1 - y )];
233- pDst8 = & (pointerColor -> xorMaskData [y * xorStep ]);
235+ const BYTE * pSrc8 = & pixels [(width * bpp ) * (height - 1 - y )];
236+ BYTE * pDst8 = & (pointerColor -> xorMaskData [y * xorStep ]);
234237
235238 andBit = 0x80 ;
236239 andBits = & (pointerColor -> andMaskData [andStep * y ]);
237240
238- for (UINT32 x = 0 ; x < width ; x ++ )
241+ for (size_t x = 0 ; x < width ; x ++ )
239242 {
240- B = * pSrc8 ++ ;
241- G = * pSrc8 ++ ;
242- R = * pSrc8 ++ ;
243- A = * pSrc8 ++ ;
243+ BYTE B = 0 ;
244+ BYTE G = 0 ;
245+ BYTE R = 0 ;
246+ BYTE A = 0 ;
247+
248+ const UINT32 color = FreeRDPReadColor (& pSrc8 [x * bpp ], format );
249+ FreeRDPSplitColor (color , format , & R , & G , & B , & A , NULL );
244250
245251 andPixel = 0 ;
246252
0 commit comments