Guest Cokegod Posted August 18, 2002 Posted August 18, 2002 I can not figure out how to get BitBlt to work in VB.Net. I use the function call of: Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) As Long But there are longer any hdc that i can find and i can't get the raster ops to work(ie srccopy) Thanks Quote
*Gurus* divil Posted August 18, 2002 *Gurus* Posted August 18, 2002 Avoid using these APIs if at all possible, .NET has GDI+ functions which do pretty much everything you need, except raster ops. You *can* use BitBlt successfully, but in order to get an hDC you must call the GetHdc method of the Graphics class. Don't forget to call the ReleaseHdc method when you're done! Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Gurus* divil Posted August 18, 2002 *Gurus* Posted August 18, 2002 Oh, and your declare statement is going to have to change too. Wherever you see a Long datatype in an API declare, change it to Integer. Also, some of those Integers are going to have to be IntPtrs, certainly when you actually pass an hDC to it. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Guest Cokegod Posted August 18, 2002 Posted August 18, 2002 so is there a way that GDI+ will do a transparent background for a bitmap. EX set the color to white so whereever there is white in the bitmap i will see the form or whatever is underneath the picture. Quote
*Gurus* divil Posted August 18, 2002 *Gurus* Posted August 18, 2002 Yes, there is a MakeTransparent method of the Bitmap class. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Guest Cokegod Posted August 20, 2002 Posted August 20, 2002 If I use the maketransparent method on a bitmap then put it into a picture box, it will take what ever the "main" color of the bitmap is and make that the background. I have a basically yellow pic with a white background and when i call myimage.maketransparent(white) it goes yellow. ??? Thanks Quote
Guest Cokegod Posted August 20, 2002 Posted August 20, 2002 Nevermind the colors later in my code i changed the backcolor, but now that i never change the backcolor they still go gray rather than transparent Quote
Guest Cokegod Posted August 22, 2002 Posted August 22, 2002 Sorry that last post was illegible. What i was trying to say was that the multiple colors was a mistake i found later in my code, BUT the back color changes to gray when i call the make transparent. Does putting the bitmap into an imagebox change the transparency back to a color??? Quote
Recommended Posts