473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem reading small icon from database

I have an application with a document management form. When users add
documents to the form, I call the API function SHGetFileInfo to get
the associated large and small icons for the file. These icons are
added to two ImageList objects which are bound to a ListView control,
and everything looks great. I am saving the icons to a SQL Server
table by using Icon.Save to a stream and assigning the byte array to
the field, then loading them back when I open the form.

Here's the problem: the large icons load fine but the small ones give
an error stating "Invalid Parameter Used". Below are the two routines
for saving and loading the icons:

Public Function IconToBytes(ByVal icon As Icon) As Byte()
'Converts an Icon object into an array of bytes so
'it can be saved to a database field
Dim loMemoryStream As New IO.MemoryStream
icon.Save(loMemoryStream)
Dim laIcon(loMemoryStream.Length - 1) As Byte
loMemoryStream.Position = 0
loMemoryStream.Read(laIcon, 0, loMemoryStream.Length)
Return laIcon
End Function

Public Function DataFieldToImage(ByVal oField As Object) As Image
'Converts an array of bytes to an Icon object when read
'from a database field.
If Not IsDBNull(oField) Then
Dim laImage() As Byte = oField
Dim loMemoryStream As New IO.MemoryStream(laImage)
Return Image.FromStream(loMemoryStream)
Else
Return Nothing
End If
End Function

I could not figure out how to load directly into an Icon object, so it
is loading into an Image object. Does ImageFormat.Icon require 32x32
to create, and if so, why am I able to assign it using
Icon.FromHandle(SHI.hIcon) when I use SHGetFileInfo to retrieve the
icons; I suppose because the icon already exists in memory?

I tried using the routine below with various image formats to save in
something other than Icon format but the transparency is always lost,
and since I am loading Icons, I can't set the ImageList Transparent
color, as I need true transparency.

For now, I am using the large icon for both large and small image
lists and letting the small image list shrink the image to 16 x 16.
But, the image quality is not as good.

Any advise would be greatly appreciated. Thanks in advance.
Nov 20 '05 #1
0 1461

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: NohaKhalifa | last post by:
Dear All; I'm developing a web site and i need to make adminisration for this site it's a site for Real Estates . But I don't need the administration to be online .. I want them to fill data...
9
by: Randall Sell | last post by:
Can anyone confirm if I am being an idiot, or is this a bug in the CSS implementation of Netscape 7.x/Mozilla 1.4 ... give the following single HTML: <html> <head> <style type="text/css">...
10
by: Zeljko | last post by:
Hi, I have a form with a tray icon. However, when I minimize the form, it stays visible - not in the task bar (I have showintaskbar property set to false), but in a form of a rectangle sitting...
2
by: Brian | last post by:
Dear my friends, I have been helped by many C# gurus here, thank you very much. My small application can help you fetch some good pictures from Internet. You can get it from...
3
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These...
2
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import...
1
by: Steve F | last post by:
I'm having a timeout problem with NotifyIcon.ShowBalloonTip, but not the problem commonly found. Most people complain that the balloon shows up too long (even though this is by design... I've...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
2
by: swethak | last post by:
Hi, I am developing the google application. In my google.js file consists the icon1=new GIcon(); icon1.image = "images/bmw-small.png"; icon1.shadow = "images/shadow50.png";...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.