|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How can I convert a graphics object to image?I've got this problem: I loaded an icon (with alpha and smoothing) into a graphics object. Now I want to display it. The best solution would be if I could convert it into an image object so the picture box can display it. Does anybody have an idea how I could do that? Thanks a lot in advance. Best Regards, HKSHK This is my source code: 'START Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As IntPtr, ByVal lpszExeFileName As String, ByVal nIconIndex As Int32) As IntPtr Private sub Test (ByVal ExeOrDLL As String, ByVal ResourceID As Int32) hIcon = ExtractIcon(IntPtr.Zero, ExeOrDLL, ResourceID) ico = Icon.FromHandle(hIcon) Dim g As Graphics = Me.PictureBox1.CreateGraphics g.CompositingQuality = Drawing2D.CompositingQuality.HighQuality g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias g.DrawIcon(ico, 0, 0) 'END When calling it as Test ("C:\windows\system\user32.dll", 3) the function will show the "Critical" icon (like MsgBox). "HKSHK" <hk***@gmx.net> schrieb: In addition to the reply I have given in the German VB.NET group, you may > When calling it as Test ("C:\windows\system\user32.dll", 3) the > function will show the "Critical" icon (like MsgBox). want to check out 'SystemIcons' which provides easy access to message box icons. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> I found a solution, which doesn't convert the icon into bitmap without
loss, but at least updates it if necessary (when it was covered before). Const IconX1 As Byte = 12 Const IconY1 As Byte = 12 Private IconX2 As Byte = 0, IconY2 As Byte = 0 Private x As Byte = 0, y As Byte = 0 Private g As Graphics = Me.CreateGraphics Private Ico As Icon Private UpdateIcon As Boolean = False Private g As Graphics = Me.CreateGraphics Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load g.CompositingQuality = Drawing2D.CompositingQuality.HighQuality g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBilinear g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias Ico = SystemIcons.Error IconX2 = IconX1 + Ico.Width IconY2 = IconY1 + Ico.Height End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint UpdateIcon = False For x = IconX1 To IconX2 For y = IconY1 To IconY2 If e.ClipRectangle.Contains(x, y) = True Then g.DrawIcon(Ico, 0, 0) UpdateIcon = True Exit For End If Next y If UpdateIcon = True Then Exit For End If Next x End Sub
Diff between 'n-tier' vs 'distributed architecture' vs. 'multi-layered programming'?
Please, can anyone convert the following dot net snippet to pascal list of objects vs Array of objects Loop Question Read Javascript Messagebox content from webclient get create table script for a SQL Server object sound capture (record audio input) in VB.NET???? Why this warning in IDE? Photoshop from vb Q: Excel files |
|||||||||||||||||||||||