Hmm.... I tried recreating the file using the other program(which uses the same values in bmp and bfh) using the CREATE_NEW definition in the CreateFile() function. When I do this, the resulting image cannot be drawn by windows picture and fax viewer. This may be the problem...
You're not giving us a lot to work with in how you're doing it but sounds like it might be an order of operations issue. You draw your rectangle first and then the datagrid draws over it. That's why when you set it to invisible, it doesn't tromp all over your rectangle.
If you don't have the data, you're just another a**hole with an opinion.
I don't htink GDI+ does anything with DPI. You can set DPI in code tho, if you need to try that.
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
I just posted this in the VB group, but then realized that this is most likely the proper place to post my question. Here it goes:
I have opened an image as a bitmap using GDI+. Before I save it I want to know if the image has transparency in it. That is; is there any pixels in the bitmap that has the transparent color? I have made a solution that looks like this:
Dim objImage As Drawing.Bitmap = Drawing.Image.FromFile("png_with_transparent_bg.png")
Dim booTransparentColorFound As Boolean = False
If Bitmap.IsAlphaPixelFormat(objImage.PixelFormat) Then
For y As Integer = 0 To objImage.Height - 1
If booTransparentColorFound Then Exit For
For x As Integer = 0 To objImage.Width - 1
Dim objColor As Drawing.Color = objImage.GetPixel(x, y)
If objColor.A = Color.Transparent.A And _
objColor.R = Color.Transparent.R And _
objColor.G = Color.Transparent.G And _
objColor.B = Color.Transparent.B _
booTransparentColorFound = True
The problem is that if the image is very big, and there is no transparent pixel in it (or a transparent pixel is located in the lower right corner), the routine is very slow. Is there some quicker way to determine if there is transparency in the image?
There are two things you could do (first way will not speed up the processing but is just a method improvement):
1) Only need to check the alpha channel (assuming any transparent colour is counted)... If objColor.A != 255 Then ...
(As the alpha channel IS the 'trasparency' aspect of the colour, you only need to check this).
2) Lock the Bitmap and loop through the raw data (this is REALLY fast)... loads of examples on web... from msdn[^]
Also... if all you want to know is if the image could contain transparency... check the PixelFormat of the bitmap for transparency.
Hope this helps.
Last Visit: 31-Dec-99 18:00 Last Update: 22-Sep-23 19:47