Bitmap usage

  • Thread starter Thread starter Jan Klaver
  • Start date Start date
J

Jan Klaver

I am running into a problem using offscreen drawing
techniques.

I've defined an offscreen bitmap and copied an embedded
resource (JPG) to the bitmap. Next I use some graphic
functions to the bitmap to draw stuff onto the JPG. The
weird thing now is that polygons, lines etc. get drawn as
if they were drawn to the bitmap first as they appear to
be behind the JPG.

Is this some property I can set or clear?
I haven't been able to solve it yet.

Regards,
Jan
 
I will show here some pieces of code that I use to get it
done.
I've created a bitmap with a full-size of a PDA-screen as
shown in the 2 dims below.

----------
Dim bmpOff As Bitmap = New Bitmap(240, 320)
Dim gxOff As Graphics = Graphics.FromImage(bmpOff)
-----------

Then I set the attributes to 0 as I don't now yet what to
do with them.

Dim imgatr As Imaging.ImageAttributes = New
Imaging.ImageAttributes

imgatr.SetColorKey(bmpOff.GetPixel(0, 0), bmpOff.GetPixel
(0, 0))

imgatr.ClearColorKey()

---------------

Then I draw an embedded resource (JPG) to the offscreen
bitmap.
Next I draw a polygon. (circles, lines and other stuff
that needs to cover the JPG)

gxOff.DrawImage(MyImage, New Rectangle(40, 111,
120, 120), _
New Rectangle(0, 0, Me.backgroundImage.Width,
Me.backgroundImage.Height), _
GraphicsUnit.Pixel)

gxOff.FillPolygon(bBrush, anglepoints)

(But this gets drawn behind the jpg that was copied the
the offscreen bitmap, as if I
created the polygon first.
I would asume it would be drawn on top of the JPG)

-----------
Here is where I check the result in the visible world.

gxOn.DrawImage(bmpOff, New Rectangle(40, 111, 120,
120), _
20, 111, 140, 140,
GraphicsUnit.Pixel, imgatr)

----------------------

This works with the above mentioned side effect. Where
there is no JPG data in the bitmap, I see the other
graphics programming appear.

I do think I must be missing out on something, but I only
have big ?????
 
I did manage now to get around the problem by creating 2
offscreen bitmaps. In the first (bitmap A) I copy my JPG,
in the second (bitmap B) I create all other stuff,
polygons, lines etc.

Then I copy the content of bitmap B to A and that works!
That 'sum' I copy the to visible world.

Has an another advantage... that I can set set up a range
of bitmaps now with some pre-processed graphics and these
layers will be fast enough to do the effects I need.

Thanks for the listening ear Alex and Geoff!


Jan
 
Back
Top