473,748 Members | 9,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why the Bitmap.MakeTran sparent() changes the PixelFormat ?

Hello Experts,

I'm creating a bitmap object like this:
Bitmap myImage = new Bitmap(1024, 1024,
System.Drawing. Imaging.PixelFo rmat.Format24bp pRgb);

But when I invoking the function myImage .MakeTransparen t() (with or without
parameters), the myImage.PixelFo rmat 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 7532
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*****@newsgr oups.nospam> wrote in message
news:1A******** *************** ***********@mic rosoft.com...
Hello Experts,

I'm creating a bitmap object like this:
Bitmap myImage = new Bitmap(1024, 1024,
System.Drawing. Imaging.PixelFo rmat.Format24bp pRgb);

But when I invoking the function myImage .MakeTransparen t() (with or
without
parameters), the myImage.PixelFo rmat 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.MakeTran sparent() changes the PixelFormat ?
thread-index: AcY7hrr3oc/UTJpZQTCPevbYtO uRWQ==
X-WBNR-Posting-Host: 199.203.93.141
From: =?Utf-8?B?U2hhcm9u?= <Sh*****@newsgr oups.nospam>
Subject: Why the Bitmap.MakeTran sparent() changes the PixelFormat ?
Date: Mon, 27 Feb 2006 02:15:27 -0800
Lines: 15
Message-ID: <1A************ *************** *******@microso ft.com>
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.publi c.dotnet.langua ges.csharp
NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
Path: TK2MSFTNGXA01.p hx.gbl!TK2MSFTN GXA03.phx.gbl
Xref: TK2MSFTNGXA01.p hx.gbl microsoft.publi c.dotnet.langua ges.csharp:3886 02
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp

Hello Experts,

I'm creating a bitmap object like this:
Bitmap myImage = new Bitmap(1024, 1024,
System.Drawing .Imaging.PixelF ormat.Format24b ppRgb);

But when I invoking the function myImage .MakeTransparen t() (with or withoutparameters), the myImage.PixelFo rmat 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
2925
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 exceptions, does anyone know what it might be I am of course using try catch and finally blocks to ensure in cases of exceptions resources get released, I just can't understand why i'm always getting this exception Help me people of the newsgroups,...
0
1859
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 background. But i use scroll bars if the image is too big for the client area. When i scroll down the screen cannot redraw itself correctly. If i dont use the transparent method and the background is black it does not do this. I saw in the...
2
3703
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 Bitmap(Width,Height,PixelFormat.Format24bppRgb); i have a bitmapdata class and then lock the bits like this. bitmapData = bitmap.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
4
23880
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 bitmap object. How to do this with C#? Any hints? Thank you very much. Best regards. Xiaoguang
3
33572
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
10782
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
2961
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 am NOT loading the picture into a form and there are no paint events to consider. I am simply loading the image from the clipboard and saving it to a file. Anyone have a solution or workaround?? Here is the code snippet...
4
10517
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 Bitmap GetClonedBitmap(int width, int height, string str, Font font, StringAlignment Alignment) { Rectangle r = new Rectangle(1, 1, width-1, height-1); using (Bitmap tmpBmp = new Bitmap(width, height)) {
1
1933
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 cannot be created for indexed PixelFormats, I am not sure how to edit the Bitmap. I am assuming that there is some class or technique other than the following: Dim bmpdata As BitmapData = bmp.LockBits(New Rectangle(0, 0, bmp.Width, bmp.Height),...
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9367
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.