TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ksmloh
NA
42
0
colorkey problem for DirectDraw
Nov 28 2003 4:24 AM
I have a 24 bit BMP image with 96x96 tiles, with a background color (which is neither black or white) for transparency. It is loaded on to a surface of smaller size so as expected the image is shrunk according to the surface size. But as a result, there was no transparency, somehow the color has changed. But if i load the image with the correct size, it works. Even by loading onto a surface half the image size, it works... I included an excerpt from my code that I used for converting the color key from RGB to the integer color value. ///
/// Counts the width of bits. ///
private byte countBitWidth( int _i ) { uint i = (uint)_i; while((i&1)==0) i>>=1; byte w=0; while(i!=0) { i >>= 1; w++; } return w; } ///
/// Converts a Color into a fill value. ///
private uint colorToFill( Color c , DirectDrawSurface7 surface) { byte widthR,widthB,widthG; // compute the bit shift width for color fill DDPIXELFORMAT pixelFormat = new DDPIXELFORMAT(); surface.GetPixelFormat( ref pixelFormat ); widthR = countBitWidth(pixelFormat.lRBitMask); widthG = countBitWidth(pixelFormat.lGBitMask); widthB = countBitWidth(pixelFormat.lBBitMask); uint x = 0; x |= ((uint)c.R)>>(8-widthR); x <<= widthG; x |= ((uint)c.G)>>(8-widthG); x <<= widthB; x |= ((uint)c.B)>>(8-widthB); return x; } Is there anyone who can solve this problem?
Reply
Answers (
2
)
Surface.Lock makes no sense at least to me
opengl transparency question