Respect
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
>.
>
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
>.
>
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.
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
OA Sistemi Srl
Traversa Via Santeramo n.15
70023 Gioia del Colle (BA)
Tel. 080-348.27.55 / 66
Fax 080-348.28.20