Click here to Skip to main content
15,911,646 members
Home / Discussions / C#
   

C#

 
GeneralRe: Resizing Gif-images that is transparent Pin
Guffa25-Jul-05 3:47
Guffa25-Jul-05 3:47 
GeneralRe: Resizing Gif-images that is transparent Pin
thomasa8-Aug-05 1:57
thomasa8-Aug-05 1:57 
I'm creating small icons of images in an ASP page, so 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):

public Bitmap _bitmap = null;
private void getGraphicsFromImageNotStretched(MemoryStream ms, int hight, int width)
{
Image image = Image.FromStream(ms, true);

double orgHight = (double)image.Height;
double orgWidth = (double)image.Width;
if((orgHight * hight) > (orgWidth * width))
{
double ratio = (orgWidth * width) / (orgHight * hight);
_bitmap = new Bitmap(image, (int)((double)width * ratio), hight);
_bitmap.Palette = image.Palette;
_bitmap.MakeTransparent();
}
else
{
double ratio = (orgHight * hight) / (orgWidth * width);
_bitmap = new Bitmap(image, width, (int)((double)hight * ratio));
_bitmap.Palette = image.Palette;
_bitmap.MakeTransparent();
}

image.Dispose();
}



Then I write the data to the output stream:

public static byte[] GenerateImageBytes(Bitmap theBitmap)
{
byte[] bytes = null;

// save the image to the output stream
System.IO.MemoryStream ms = new System.IO.MemoryStream();
theBitmap.Save(ms, ImageFormat.Png);
bytes = ms.ToArray();
ms.Close();

return bytes;
}


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

Thanks
Thomas
GeneralRe: Resizing Gif-images that is transparent Pin
Guffa8-Aug-05 22:55
Guffa8-Aug-05 22:55 
GeneralRe: Resizing Gif-images that is transparent Pin
thomasa9-Aug-05 1:06
thomasa9-Aug-05 1:06 
GeneralSimple Problem Pin
tatchung13-Jul-05 22:07
tatchung13-Jul-05 22:07 
GeneralRe: Simple Problem Pin
Expert Coming14-Jul-05 8:35
Expert Coming14-Jul-05 8:35 
GeneralRe: Simple Problem Pin
tatchung14-Jul-05 15:18
tatchung14-Jul-05 15:18 
GeneralRe: Simple Problem Pin
Christian Graus14-Jul-05 15:53
protectorChristian Graus14-Jul-05 15:53 
GeneralRe: Simple Problem Pin
tatchung14-Jul-05 16:03
tatchung14-Jul-05 16:03 
GeneralRe: Simple Problem Pin
Christian Graus14-Jul-05 16:15
protectorChristian Graus14-Jul-05 16:15 
GeneralRe: Simple Problem Pin
tatchung14-Jul-05 16:22
tatchung14-Jul-05 16:22 
QuestionWhat mistake in this Asynchronous webservice Pin
Vinkum13-Jul-05 21:33
Vinkum13-Jul-05 21:33 
GeneralSet Time Zone Information in Windows CE Pin
myanne13-Jul-05 21:29
myanne13-Jul-05 21:29 
Generalc# code Pin
manar113-Jul-05 21:28
manar113-Jul-05 21:28 
GeneralRe: c# code Pin
J4amieC13-Jul-05 22:56
J4amieC13-Jul-05 22:56 
QuestionSOAP client in Windows Service - memory leak?? Pin
teddy_bear13-Jul-05 21:06
teddy_bear13-Jul-05 21:06 
Generalcrystal report Pin
yitong13-Jul-05 20:34
yitong13-Jul-05 20:34 
GeneralRe: crystal report Pin
User 209307313-Jul-05 21:30
User 209307313-Jul-05 21:30 
GeneralConsole App Input Pin
Expert Coming13-Jul-05 20:15
Expert Coming13-Jul-05 20:15 
GeneralRe: Console App Input Pin
seee sharp13-Jul-05 22:34
seee sharp13-Jul-05 22:34 
GeneralWindows Service Pin
ksanju100013-Jul-05 20:15
ksanju100013-Jul-05 20:15 
GeneralRe: Windows Service Pin
Vasudevan Deepak Kumar14-Jul-05 5:16
Vasudevan Deepak Kumar14-Jul-05 5:16 
GeneralWindows Service in c# Pin
ksanju100013-Jul-05 20:14
ksanju100013-Jul-05 20:14 
GeneralRe: Windows Service in c# Pin
Dave Kreskowiak14-Jul-05 4:18
mveDave Kreskowiak14-Jul-05 4:18 
Generaltree view issues Pin
Anonymous13-Jul-05 17:31
Anonymous13-Jul-05 17:31 

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.