473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Why the Bitmap.MakeTransparent() changes the PixelFormat ?

Hello Experts,

I'm creating a bitmap object like this:
Bitmap myImage = new Bitmap(1024, 1024,
System.Drawing.Imaging.PixelFormat.Format24bppRgb) ;

But when I invoking the function myImage .MakeTransparent() (with or without
parameters), the myImage.PixelFormat changes to Format32bppArgb.

Why is that and how can I avoid it but still making the Bitmap transparent ?
----------
Thakns
Sharon
Feb 27 '06 #1
2 7479
The 24bpp pixel format doesn't define transparency (Alpha) and so the system
automatically changes to a format that can express the transparent value.

There is no way to display a 24bpp image with transparency on a per-pixel
basis.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Sharon" <Sh*****@newsgroups.nospam> wrote in message
news:1A**********************************@microsof t.com...
Hello Experts,

I'm creating a bitmap object like this:
Bitmap myImage = new Bitmap(1024, 1024,
System.Drawing.Imaging.PixelFormat.Format24bppRgb) ;

But when I invoking the function myImage .MakeTransparent() (with or
without
parameters), the myImage.PixelFormat changes to Format32bppArgb.

Why is that and how can I avoid it but still making the Bitmap transparent
?
----------
Thakns
Sharon

Feb 27 '06 #2
Hi Sharon,
Generally speaking, 24bit only includes RGB (three colors), not include
alpha value. So it can't produce transparent effect. I think this is the
reason when invoking the function MakeTransparent(), the PixelFormat
changes to Format32bppArgb. Because it will need alpha value(8 bits) to
generate transparent effect.
Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security

--------------------
Thread-Topic: Why the Bitmap.MakeTransparent() changes the PixelFormat ?
thread-index: AcY7hrr3oc/UTJpZQTCPevbYtOuRWQ==
X-WBNR-Posting-Host: 199.203.93.141
From: =?Utf-8?B?U2hhcm9u?= <Sh*****@newsgroups.nospam>
Subject: Why the Bitmap.MakeTransparent() changes the PixelFormat ?
Date: Mon, 27 Feb 2006 02:15:27 -0800
Lines: 15
Message-ID: <1A**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.languages.csharp:388602
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Hello Experts,

I'm creating a bitmap object like this:
Bitmap myImage = new Bitmap(1024, 1024,
System.Drawing.Imaging.PixelFormat.Format24bppRgb );

But when I invoking the function myImage .MakeTransparent() (with or withoutparameters), the myImage.PixelFormat changes to Format32bppArgb.

Why is that and how can I avoid it but still making the Bitmap transparent ?

----------
Thakns
Sharon


Feb 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jax | last post by:
Whenever I use this method I get out of memory exception, even when using tiny bitmaps (100X100) Does anyone know why this is From what I remember OutOfMemory Exception is a default for other...
0
by: James Dean | last post by:
I am drawing to an offscreen bitmap various shapes and so on. I have created a bitmap for this purpose. But the bitmap has a black background so i used the make transparent method to clear the...
2
by: James Dean | last post by:
I create a bitmap like this. The width and height are got from the compressed file i am reading. The width and height are in pixels.....1bpp bitmap = new...
4
by: Ma Xiaoguang | last post by:
Dear ladies and gentlemen: How to access all the pixels of a bitmap with C#? I am working with Delphi before. In Delphi, you can use TBitmap.Scanline property to access all the pixels of a...
3
by: Flix | last post by:
Is there some way to convert a Bitmap from one PixelFormat (16bit or with indexed colors) to another(24bit), without doing per pixel operations?
8
by: nobody | last post by:
How do I save a PictureBox bitmap with changes drawn on the bitmap? This doesn't do it: PictureBox1.Image.Save("key30.bmp")
0
by: BIG_j | last post by:
I have dynamic image(s) on the clipboard that I need to save as a transparent gif. There are a number of posts regarding MakeTransparent but I cannot get this to work for what I am trying to do. I...
4
by: John J. Hughes II | last post by:
The following code throws a out of memory exception, I have another function that does the same thing using the bitmap lock but its way slow. Anyone know how to fix this one? public static...
1
by: Nathan Sokalski | last post by:
I have created declared a Bitmap using the following statement: Dim bmp As New Bitmap(100, 100, PixelFormat.Format8bppIndexed) Because the SetPixel() method is disabled and a Graphics object...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.