Forum Xamarin.Android

Bitmap Alteration on Thread causes Distortion

pmhart83pmhart83 USMember ✭✭✭
edited December 2014 in Xamarin.Android

Working in the care free world of Android bitmaps today (ya right). I am working on a music app that changes pages. There are 3 main bitmaps I am concerned with: the current page notation, the next page notation and the overlay red notes.

The red overlay bitmap seems to be fine on it's own. I am having problems when there is a page change. After a page change the current page bitmap draws the bitmap from the next page and the next page generates a new rendering on a thread.

The first page turn works perfectly. But when it gets to page 3 I see artifacts from the "red note" bitmap on the notation bitmap? How can two unrelated bitmaps end up drawing on each other unless it's just a glitch in Android threading?

This might help illustrate my situation:

Bitmap 1 = Current Page

Bitmap 2 = Cached Next Page

Bitmap 3 = Red Rendering of Current Page (same parent view as Bitmap 1)

[Start Playing]

Bitmap 1 stays at page 1 and does nothing

Bitmap 2 Generates Next Page

Bitmap 3 Generates Red Rendering

[Page 2]

Bitmap 1 draws Bitmap 2 on to it using a canvas

Bitmaps 2 Generates Next Page (page 3)

Bitmaps 3 Generates Red Rendering of Page 2

[Page 3]

"same as page 2" ... except I see red artifacts mixed in after Bitmap 2 is drawn to Bitmap 1. Neither of these two bitmaps ever even draw a red note. I checked my canvas drawing code to make sure that the red dot drawing is not somehow referencing bitmap 1 or bitmap 2.

I could more so understand if Bitmap 1 and Bitmap 2 had black artifacts, but why is the canvas.Draw(otherPage.Bmp) showing red artifacts? I can't figure it out ...

Sign In or Register to comment.