Best way to alpha blend over a bitmap.
- From: "Henry Padilla" <padillah@xxxxxxxxxxx>
- Date: Thu, 23 Feb 2006 14:35:00 -0500
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
256x128).
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
tracking.
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.
.
- Prev by Date: Re: WebRequest times out...but only 3rd time and on...
- Next by Date: Re: reference to external file in streamwriter
- Previous by thread: Converting DOS date to mmddyyyy format in C#
- Next by thread: Extend a Predefined Enum
- Index(es):
Relevant Pages
|