Click here to Skip to main content
15,908,907 members
Home / Discussions / C#
   

C#

 
Generalchange border width and color of panel Pin
yonitgil24-Nov-04 3:27
yonitgil24-Nov-04 3:27 
GeneralRe: change border width and color of panel Pin
Heath Stewart24-Nov-04 10:43
protectorHeath Stewart24-Nov-04 10:43 
GeneralRe: change border width and color of panel Pin
yonitgil27-Dec-04 21:45
yonitgil27-Dec-04 21:45 
GeneralRe: change border width and color of panel Pin
Heath Stewart28-Dec-04 5:11
protectorHeath Stewart28-Dec-04 5:11 
GeneralGet data from the clipboard Pin
lmaks24-Nov-04 3:22
lmaks24-Nov-04 3:22 
GeneralRe: Get data from the clipboard Pin
Heath Stewart24-Nov-04 6:24
protectorHeath Stewart24-Nov-04 6:24 
GeneralICO to JPEG Pin
CyberTech24-Nov-04 2:19
CyberTech24-Nov-04 2:19 
GeneralRe: ICO to JPEG Pin
Heath Stewart24-Nov-04 10:17
protectorHeath Stewart24-Nov-04 10:17 
Since JPEG doesn't support an alpha channel (ever considered saving as a GIF or PNG instead?) and you can't just say "set a background color". You can make colors transparent, but that's not your problem (quite the opposite, in fact).

Instead you'll need to parse the ICO format that is documented in http://msdn.microsoft.com/library[^] to get the palette, then get the transparency mask (IIRC, it's the first color in the palette). Finally, use Bitmap.LockBits, enumerate each pixel and use Bitmap.GetPixel to determine if that color is the same as the mask, then use Bitmap.SetPixel to set the color for the transparent pixel. When you're all done, use Bitmap.UnlockBits and save the image.

Another way is to create a Bitmap of the same size, set the background color, then get a Graphics object for the Bitmap and draw the icon onto the new bitmap. Save it as whatever format you like.

Honestly, saving this as a GIF or PNG (supports true alpha channels; GIF supports only masks and only 256 colors) would be much easier and are also widely used formats.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralQuery on Scrolling Pin
pradeep_pc24-Nov-04 0:46
pradeep_pc24-Nov-04 0:46 
GeneralRe: Query on Scrolling Pin
Daniel Turini24-Nov-04 1:09
Daniel Turini24-Nov-04 1:09 
GeneralProgramatically place characters in an input stream Pin
SebbaP24-Nov-04 0:42
SebbaP24-Nov-04 0:42 
GeneralRe: Programatically place characters in an input stream Pin
Daniel Turini24-Nov-04 1:02
Daniel Turini24-Nov-04 1:02 
GeneralComparing Strings with Wildcards Pin
pjholliday23-Nov-04 23:48
pjholliday23-Nov-04 23:48 
GeneralRe: Comparing Strings with Wildcards Pin
Stefan Troschuetz24-Nov-04 0:23
Stefan Troschuetz24-Nov-04 0:23 
QuestionSystem-wide CBT in .NET? Pin
Hadi Fakhreddine23-Nov-04 22:58
Hadi Fakhreddine23-Nov-04 22:58 
AnswerRe: System-wide CBT in .NET? Pin
Heath Stewart24-Nov-04 6:19
protectorHeath Stewart24-Nov-04 6:19 
GeneralRe: System-wide CBT in .NET? Pin
Hadi Fakhreddine24-Nov-04 6:36
Hadi Fakhreddine24-Nov-04 6:36 
GeneralRe: System-wide CBT in .NET? Pin
Heath Stewart24-Nov-04 8:23
protectorHeath Stewart24-Nov-04 8:23 
GeneralRe: System-wide CBT in .NET? Pin
Hadi Fakhreddine24-Nov-04 20:50
Hadi Fakhreddine24-Nov-04 20:50 
QuestionHow to Update Primary keys? Pin
Old Gun23-Nov-04 21:22
Old Gun23-Nov-04 21:22 
AnswerRe: How to Update Primary keys? Pin
sreejith ss nair24-Nov-04 3:59
sreejith ss nair24-Nov-04 3:59 
AnswerRe: How to Update Primary keys? Pin
Heath Stewart24-Nov-04 6:14
protectorHeath Stewart24-Nov-04 6:14 
GeneralHave no node selected or Hide Tree view first Node Pin
tejas_kan23-Nov-04 20:45
tejas_kan23-Nov-04 20:45 
GeneralRe: Have no node selected or Hide Tree view first Node Pin
Daniel Turini24-Nov-04 1:04
Daniel Turini24-Nov-04 1:04 
GeneralRe: Have no node selected or Hide Tree view first Node Pin
Anonymous24-Nov-04 1:11
Anonymous24-Nov-04 1:11 

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.