471,319 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Best way to alpha blend over a bitmap.

I'm writing an app that creates a bitmap of a map (land, trees, ocean). The
resolution of the map is ~84x52 (it can change but will get no larger than

Since this is so small I resize it (using NearestNeighbor to retain the
definition between squares) to a larger size. I have two QoS points: 1) I
would like to keep the resizing fast enough to have it attached to the
window Resize event; and 2) I would like to create an alpha blended red
square to float, constrained by the resolution of the map (I want it to snap
to each square, not just float around), to help the user see what square
they are pointing to.

To do this I tried to use GDI+ to resize the map using NearestNeighbor.
This worked plenty fast enough and I could use a little math to find where
the click on the bitmap translated to on the land map. One problem I
noticed right away, the border squares were only half as big as squares
inside the bitmap.

When I tried to add the floating red square the same math did not work in
reverse and usually ended up about half a square off. Also, the additional
bitmap took quite a bit longer to render and is way too slow for mouseover

Since I could not get the math to work right I finally decided to draw the
bit map myself then I could draw the same size bitmap with a red pixel where
I wanted it and overlay the two. Now the map takes too long to render and
has gaps between the boxes (look like grid lines) because the resizing isn't
always on a factor of the height or width.

So I need to know, what is the fastest way to draw a bitmap, resize a
bitmap, not have gaps in the resized bitmap, and alpha blend a red square on
top of all that bound by the resolution of the original map?

Other than that I'm all set.

Thanks in advance,
Tom P.
Feb 23 '06 #1
0 4165

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Nuno Esculcas | last post: by
3 posts views Thread by instruo | last post: by
1 post views Thread by RicercatoreSbadato | last post: by
3 posts views Thread by :\\\\derian | last post: by
6 posts views Thread by tommaso.gastaldi | last post: by
3 posts views Thread by Gernot Frisch | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.