@@ -69,6 +69,8 @@ void NGAGE_DestroyTextureData(NGAGE_TextureData *data)
69
69
if (data) {
70
70
delete data->bitmap ;
71
71
data->bitmap = NULL ;
72
+ delete data->mask ;
73
+ data->mask = NULL ;
72
74
}
73
75
}
74
76
@@ -350,7 +352,29 @@ bool CRenderer::Copy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rec
350
352
if (phdata->bitmap ) {
351
353
TRect aSource (TPoint (srcrect->x , srcrect->y ), TSize (srcrect->w , srcrect->h ));
352
354
TPoint aDest (dstrect->x , dstrect->y );
353
- iRenderer->Gc ()->BitBlt (aDest, phdata->bitmap , aSource);
355
+
356
+ w = phdata->surface ->w ;
357
+ pitch = phdata->surface ->pitch ;
358
+ Uint16 *src = (Uint16 *)phdata->surface ->pixels ;
359
+ Uint16 *mask = (Uint16 *)phdata->mask ->DataAddress ();
360
+
361
+ for (int y = 0 ; y < srcrect->h ; ++y) {
362
+ int src_y = srcrect->y + y;
363
+ if (src_y < 0 || src_y >= phdata->surface ->h ) {
364
+ continue ;
365
+ }
366
+ for (int x = 0 ; x < srcrect->w ; ++x) {
367
+ int src_x = srcrect->x + x;
368
+ if (src_x < 0 || src_x >= phdata->surface ->w ) {
369
+ continue ;
370
+ }
371
+ Uint16 pixel = src[src_y * (pitch / 2 ) + src_x];
372
+ Uint8 alpha = (pixel & 0xF000 ) >> 12 ;
373
+ mask[src_y * w + src_x] = (alpha == 0 ) ? 0x0000 : 0xFFFF ;
374
+ }
375
+ }
376
+
377
+ iRenderer->Gc ()->BitBltMasked (aDest, phdata->bitmap , aSource, phdata->mask , EFalse);
354
378
}
355
379
356
380
return true ;
@@ -416,7 +440,29 @@ bool CRenderer::CopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const NGAGE
416
440
if (phdata->bitmap ) {
417
441
TRect aSource (TPoint (copydata->srcrect .x , copydata->srcrect .y ), TSize (copydata->srcrect .w , copydata->srcrect .h ));
418
442
TPoint aDest (copydata->dstrect .x , copydata->dstrect .y );
419
- iRenderer->Gc ()->BitBlt (aDest, phdata->bitmap , aSource);
443
+
444
+ w = phdata->surface ->w ;
445
+ pitch = phdata->surface ->pitch ;
446
+ Uint16 *src = (Uint16 *)phdata->surface ->pixels ;
447
+ Uint16 *mask = (Uint16 *)phdata->mask ->DataAddress ();
448
+
449
+ for (int y = 0 ; y < copydata->srcrect .h ; ++y) {
450
+ int src_y = copydata->srcrect .y + y;
451
+ if (src_y < 0 || src_y >= phdata->surface ->h ) {
452
+ continue ;
453
+ }
454
+ for (int x = 0 ; x < copydata->srcrect .w ; ++x) {
455
+ int src_x = copydata->srcrect .x + x;
456
+ if (src_x < 0 || src_x >= phdata->surface ->w ) {
457
+ continue ;
458
+ }
459
+ Uint16 pixel = src[src_y * (pitch / 2 ) + src_x];
460
+ Uint8 alpha = (pixel & 0xF000 ) >> 12 ;
461
+ mask[src_y * w + src_x] = (alpha == 0 ) ? 0x0000 : 0xFFFF ;
462
+ }
463
+ }
464
+
465
+ iRenderer->Gc ()->BitBltMasked (aDest, phdata->bitmap , aSource, phdata->mask , EFalse);
420
466
}
421
467
422
468
return true ;
@@ -440,6 +486,18 @@ bool CRenderer::CreateTextureData(NGAGE_TextureData *aTextureData, const TInt aW
440
486
return false ;
441
487
}
442
488
489
+ aTextureData->mask = new CFbsBitmap ();
490
+ if (!aTextureData->mask ) {
491
+ return false ;
492
+ }
493
+
494
+ error = aTextureData->mask ->Create (TSize (aWidth, aHeight), EColor4K);
495
+ if (error != KErrNone) {
496
+ delete aTextureData->mask ;
497
+ aTextureData->mask = NULL ;
498
+ return false ;
499
+ }
500
+
443
501
return true ;
444
502
}
445
503
0 commit comments