Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

32-Bit Icons

1 view
Skip to first unread message

Warren Ayen

unread,
Aug 28, 2002, 1:26:20 AM8/28/02
to
I have created some very beautiful WindowsXP icons, each with multiple formats, a 32-bit format, an 8-bit, and a 4-bit. The 32-bit is WindowsXP, the 8-Bit is any other Windows, and the 4-bit is for 16 colors.
 
My question is: How can I use the 32-bit in VB .NET?? It always uses the 8-bit images, which do not alpha blend with the drop shadow.
 

Peter Norton

unread,
Aug 28, 2002, 7:42:36 AM8/28/02
to
Hello,
have some problem. Getting icon from *.dll, *.exe, trying
convert Icon with alpha chanel to Bitmap with method
ToBitmap() or use Graphics.DrawIcon() ( example for
combine two icons ) - and have trouble : Black pixels.
Need some help!!!
My question is: How can I convert Icon to Bitmap without
lost alpha chanel in C#??

Respect

Peter Norton

unread,
Aug 28, 2002, 7:49:32 AM8/28/02
to
Found a post with this body text :
"
You could try locking the bits and reading the alpha
information yourself.
Something like this might work:

Image img = this.imageStrip.Images[0]
Bitmap b = (Bitmap) img;
b.LockBits(...


Thanks,
-Greg
Microsoft Developer Support

"
Ok, Greg, what it means - reading the alpha information
yourself. But how ?
Help pls

Respect

>.
>

Peter Norton

unread,
Aug 28, 2002, 8:48:55 AM8/28/02
to
Hello again.
Ok, i`m trying LockBits, but it not working again.
Again A chanel in all pixels is 255

This is sample code:
-----------
//Icon ic = ....
this.imageList1.Images.Add( ic );
Bitmap bp = (Bitmap)this.imageList1.Images[ 0 ];
// or Bitmap bp = ic.ToBitmap();
BitmapData bitData = bp.LockBits(
new Rectangle( 0, 0, bp.Width, bp.Height ),
ImageLockMode.ReadOnly,
PixelFormat.Format32bppPArgb
);

IntPtr ptr = bitData.Scan0;
unsafe
{
byte* p = (byte*) ptr.ToPointer();
for ( int i = 0; i < bp.Height; i++ )
{
for ( int j = 0; j < bp.Width; j++ )
{
for ( int k = 0; k < 4; k++ )
{
Console.Write( *p );
Console.Write( " " );
p++;
}
Console.WriteLine();
}
Console.WriteLine( i + " ------------------------" );
}
}
----------
Is it right?
I think after convert icon to bitmap all information about
Alpha channel is dead.
Can anyone help me ?????
With respect
Peter

>.
>

John Hornick [MS]

unread,
Sep 4, 2002, 5:05:27 PM9/4/02
to
Hi,


I think the alpha is lost when you add it to the ImageList.

I have, in the past, added the images to the image list using Win32
APIs to retain alpha.

Thanks,
- John
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Visit http://www.microsoft.com/security for current information on security.

Vanni Wassermann

unread,
Sep 11, 2002, 10:39:11 AM9/11/02
to
You can't add a 32bit (XP style) icon to imagelist in design-time.
Probably imagelist calls the "System.Drawing.Image.FromFile" function wich
lose the 8bit alpha channel data.
You can do it in run time mode creating an icon object, then creating an
handle from it and passing it to the Add method of the imagelist.
Check this out (create a new form, delete every single line of code and
paste this code)

Public Class Form2

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.


InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

Friend WithEvents Button1 As System.Windows.Forms.Button

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.Button1 = New System.Windows.Forms.Button()

Me.SuspendLayout()

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(70, 14)

Me.Button1.Name = "Button1"

Me.Button1.Size = New System.Drawing.Size(120, 40)

Me.Button1.TabIndex = 0

Me.Button1.Text = "Button1"

'

'Form2

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 271)

Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1})

Me.Name = "Form2"

Me.Text = "Form2"

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

components = New System.ComponentModel.Container()

Dim il As New ImageList(Me.components)

il.ColorDepth = ColorDepth.Depth32Bit

il.ImageSize = New Size(48, 48)

Dim ico As New Icon("c:\xp.ico")

'il.Images.Add(System.Drawing.Image.FromFile("c:\xp.ico", True))

il.Images.Add(System.Drawing.Icon.FromHandle(ico.Handle))

Dim lv As New ListView()

lv.Location = New Point(20, 80)

lv.Size = New Size(250, 150)

lv.View = View.LargeIcon

lv.SmallImageList = il

lv.LargeImageList = il

lv.StateImageList = il

Me.Controls.Add(lv)

lv.Items.Add("Prova", 0)

End Sub

End Class

Vanni Wassermann

wasse...@oasistemi.it

OA Sistemi Srl

Traversa Via Santeramo n.15

70023 Gioia del Colle (BA)

Tel. 080-348.27.55 / 66

Fax 080-348.28.20

www.oasistemi.it

0 new messages