473,385 Members | 1,555 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,385 software developers and data experts.

Bitmap.MakeTransparent OutOfMemoryException

Jax
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, you're my only hope

jax
Nov 15 '05 #1
2 2902
Can you post code that demonstrates this? It seems to be working fine for
me.

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

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

Read my Blog at http://bobpowelldotnet.blogspot.com

"Jax" <an*******@discussions.microsoft.com> wrote in message
news:48**********************************@microsof t.com...
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, you're my only hope.

jax

Nov 15 '05 #2
Jax
It's as simple as:

(psuedo)
FileStream fs = new FileStream(@"c:\myImage.bmp", FileMode.Open);
Bitmap b = Bitmap.FromStream(fs);
try
{
Label theColour= new Label();
// client side script where the user clicks the image
int x = Convert.ToInt32(TextBox1.Text);
int y = Convert.ToInt32(TextBox2.Text);
theColour.BackColour = b.GetPixel(x,y);
b.MakeTransparent(theColour.BackColor); // Error here, OutOfMemoryException
b.SaveAs(fs, ImageFormat.Jpeg); // Occasionally error here, unspecified.
Image1.Url = "c:\myImage.Jpg";
}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
finally
{
b.Dispose();
fs.Close();
}
Nov 15 '05 #3

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

Similar topics

2
by: blackegg | last post by:
How to set Bitmap background to transparent *-----------------------* Posted at: www.GroupSrv.com *-----------------------*
1
by: Brian Keating EI9FXB | last post by:
Hello there, Does anyone know how to to Bitmap masking in .NET, In c++ i used, CreateCompatibleDC GetBitmap Then on the bitmap and the bitmap mask i called. {SelectBitmap StretchBlt}
2
by: Jax | last post by:
So far i've not had much luck with this method. Bitmap.MakeTransparent(someColor); Makes the transparent colour either a non-transparent black (.bmp, jpg or .gif) or silver (.png) i've tried...
2
by: Dennis | last post by:
I have created a bitmap and set the transparency color to black; mybitmap.MakeTransparent(Color.Black) myicon = Icon.FromHandle(bm.GetHicon) This creates the icon ok but the background color...
3
by: Dennis | last post by:
I have a bitmap and make the color transparent; mybitmap.MakeTransparent(Color.Black) When I save it as a Icon, the black color is not transparent. However, if I save it as a bitmap then...
2
by: Sharon | last post by:
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...
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...
5
by: Dale | last post by:
When I create a System.Drawing.Bitmap and save it as ImageType.GIF, how can I set the transparency so that the background is transparent. In my application, the Bitmap that I am working with has...
0
by: benfly08 | last post by:
Hi, guys. I have a program to draw bar/pie chart based on the data i hard coded in it. However, my image comes with "BLACK" background color. I don't know how to fix this. The code snippet is...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.