Click here to Skip to main content
16,008,750 members
Home / Discussions / C#
   

C#

 
GeneralRe: try catch and return value Pin
Os Sutrisno12-Aug-05 0:34
Os Sutrisno12-Aug-05 0:34 
GeneralRe: try catch and return value Pin
Colin Angus Mackay12-Aug-05 0:38
Colin Angus Mackay12-Aug-05 0:38 
GeneralRe: try catch and return value Pin
Os Sutrisno12-Aug-05 0:40
Os Sutrisno12-Aug-05 0:40 
QuestionRow colors in DataGrids? Pin
kbalias11-Aug-05 23:56
kbalias11-Aug-05 23:56 
AnswerRe: Row colors in DataGrids? Pin
Alomgir Miah12-Aug-05 6:16
Alomgir Miah12-Aug-05 6:16 
GeneralImage Capture Pin
Member 217284911-Aug-05 23:26
Member 217284911-Aug-05 23:26 
GeneralRe: Image Capture Pin
Kimocat12-Aug-05 13:35
Kimocat12-Aug-05 13:35 
GeneralResizing Gif-images that is transparent Pin
thomasa11-Aug-05 22:21
thomasa11-Aug-05 22:21 
How can I find out witch color in a Gif image that is transparent?

I'm creating small icons of images in an ASP page, and I'm writing the images to the output stream.

First I'm resizing the image, witch data I get from a memory stream (this data is an transparent image, and in this code example I use PNG to try to get transparency):

<br />
public Bitmap _bitmap = null;<br />
private void getGraphicsFromImageNotStretched(MemoryStream ms, int hight, int width)<br />
{ <br />
Image image = Image.FromStream(ms, true); <br />
<br />
double orgHight = (double)image.Height;<br />
double orgWidth = (double)image.Width;<br />
if((orgHight * hight) > (orgWidth * width))<br />
{<br />
double ratio = (orgWidth * width) / (orgHight * hight);<br />
_bitmap = new Bitmap(image, (int)((double)width * ratio), hight);<br />
_bitmap.Palette = image.Palette; <br />
_bitmap.MakeTransparent();<br />
}<br />
else<br />
{<br />
double ratio = (orgHight * hight) / (orgWidth * width);<br />
_bitmap = new Bitmap(image, width, (int)((double)hight * ratio));<br />
_bitmap.Palette = image.Palette;<br />
_bitmap.MakeTransparent();<br />
} <br />
<br />
image.Dispose(); <br />
}<br />



Then I write the data to the output stream:
<br />
public static byte[] GenerateImageBytes(Bitmap theBitmap)<br />
{<br />
byte[] bytes = null; <br />
<br />
// save the image to the output stream<br />
System.IO.MemoryStream ms = new System.IO.MemoryStream();<br />
theBitmap.Save(ms, ImageFormat.Png);<br />
bytes = ms.ToArray();<br />
ms.Close(); <br />
<br />
return bytes;<br />
}<br />


This result in an image that is not treansparent Frown | :(

If anyone has a code-snip or an example to get this working, I'll be happy as a dove.

Thanks
Thomas
Generalquestion on using ref keyword Pin
ppp00111-Aug-05 22:13
ppp00111-Aug-05 22:13 
GeneralRe: question on using ref keyword Pin
levgiang11-Aug-05 22:34
levgiang11-Aug-05 22:34 
GeneralRe: question on using ref keyword Pin
ppp00112-Aug-05 0:21
ppp00112-Aug-05 0:21 
GeneralRe: question on using ref keyword Pin
Guffa12-Aug-05 2:12
Guffa12-Aug-05 2:12 
GeneralRe: question on using ref keyword Pin
Gavin Jeffrey11-Aug-05 22:35
Gavin Jeffrey11-Aug-05 22:35 
GeneralGenerating Powerpoint from XML Pin
Sylvester, Asil Gerard11-Aug-05 22:10
Sylvester, Asil Gerard11-Aug-05 22:10 
QuestionHow to create DataColumn.Expression that calculate age. (Birthdate - Today) Pin
god4k11-Aug-05 22:04
god4k11-Aug-05 22:04 
General&quot;Hello World&quot; Pin
binglin11-Aug-05 21:41
binglin11-Aug-05 21:41 
GeneralRe: &quot;Hello World&quot; Pin
Stefan Troschuetz11-Aug-05 22:09
Stefan Troschuetz11-Aug-05 22:09 
GeneralRe: &quot;Hello World&quot; Pin
levgiang11-Aug-05 22:24
levgiang11-Aug-05 22:24 
GeneralRe: &quot;Hello World&quot; Pin
Gavin Jeffrey11-Aug-05 22:30
Gavin Jeffrey11-Aug-05 22:30 
GeneralRe: &quot;Hello World&quot; Pin
Matt Gerrans12-Aug-05 5:59
Matt Gerrans12-Aug-05 5:59 
GeneralProblem in sending the array of objects to Web services using P.D.A. work Pin
praveenpavan11-Aug-05 20:49
praveenpavan11-Aug-05 20:49 
QuestionHow to open a form when click on Datagrid in C# Pin
dwark10611-Aug-05 20:49
dwark10611-Aug-05 20:49 
AnswerRe: How to open a form when click on Datagrid in C# Pin
Gavin Jeffrey11-Aug-05 22:43
Gavin Jeffrey11-Aug-05 22:43 
GeneralRe: How to open a form when click on Datagrid in C# Pin
dwark10612-Aug-05 6:40
dwark10612-Aug-05 6:40 
Generalinput question. Pin
spepperchin11-Aug-05 20:36
spepperchin11-Aug-05 20:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.