Strange ghosting with Image and bitmaps with Glide

I have a Image that I draw a background compass type rose as shown below and then a pointer.

I draw the background first and then the pointer. When I go to redraw I am seeing a ghost of the pointer on the screen. I use the following code to draw the 2.

using (Bitmap compassCopy = new Bitmap(bitmaps.compassPointerBitmap.Width, bitmaps.compassPointerBitmap.Height))
    // Draw the initial bitmap
    compassImage.Bitmap.DrawImage(0, 0, bitmaps.compassBitmap, 0, 0, 200, 200);
    // Draw the direction arrow if there is any to display
    if (drawCompass)
        compassCopy.RotateImage(displayHeading, 0, 0, bitmaps.compassPointerBitmap, 0, 0, 220, 220, 255);

        compassImage.Bitmap.DrawImage(-10, -10, compassCopy, 0, 0, compassCopy.Width, compassCopy.Height);

The attached images show the Image after I make the call to draw the background (I inserted an Invalidate to see this - not shown in the code above. Also I included the 2 images I use. The background one has the same background colour as the main screen.

The arrow one does have an arrow in a dark gray. This was needed so I could use BLACK as the transparent colour. When I rotate this the area in the corners becomes black. :slight_smile:

@ Dave McLaughlin - I think opacity for RotateImage method should be 65535 instead of 255.

Or better yet use the pre-defined constant Bitmap.OpacityOpaque or Bitmap.OpacityTransparent depending on your intentions.

255 does not equate to Bitmap.OpacityOpaque.

1 Like

If I breakpoint and check the value of Bitmap.OpacityOpaque, it is 0x100 (256)

I still get the ghosting using Bitmap.OpacityOpaque.

I fixed it. It has to do with the image bit count. The paint software was saving automatically as 8 bit but once I saved as 24 bit the ghosting has gone. Now the display looks perfect. :slight_smile: