473,395 Members | 1,624 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,395 software developers and data experts.

Problems with ImageList.. need help

I have a problem that just cropped up with using an ImageList in my project
I am using VB .NET 200
Problem:

I have existing Form with 2 Image List controls. ImageList16 (for 16x16 Images) and ImageList24 (for 24x24). I have inserted images in each and it has worked fine for months... The System.Drawing.Bitmap properties for these images are PixelFormat=32bppArgb and RawFormat=MemoryBmp with the Horiz and VerticalResolution = 96

I installed DirectX9.0

The next time I went to add a Image to the ImageList all of my new images are being inserted as PixelFormat = Format8bppIndexed and RawFormat = Bmp with the Horiz and VertResolution = 71.9836. This is causing all my new images to not remove the transparent color

I used System Restore points to move my system configuration back prior to DirectX9 but it was to no avail... My images are still being inserted incorrectly. In fact all my older components are also now suffering from the same problem...

Things I've tried...
1. I have tried creating a new Image List but it too has the same proble
2. Changing System Color depth and resolution in different combination
Nothing has worked... I have months invested in this program and need help... The old images still work fine but I desperately need to be able to add new images. Any help or suggestions would be appreciated

Thanks

David

Nov 20 '05 #1
4 4285
Hi David,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that after you install directx9.0b, the
imagelist will not work on your machine.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Is the DirectX 9.0b you have installed the one in the windows update
website, or is it a runtime or a directx 9.0 sdk?
Based on my knowledge, the DirectX library will not impact the ImageList
which will use the comctl32.dll underlying.

Also I can not reprodue the problem that all the new image added into the
imagelist are all PixelFormat = Format8bppIndexed and RawFormat = Bmp, on
my side the two properties will depend on the real format of the image.

Have you tried to create a new windows form project and add a imagelist
,and then add a few pictures into the imagelist, did the problem persists?
If no, can you build a simple reproduce sample and post here or send to me
by removing the "online" from my email address.

But I can reproduce the problem that we can not change the transparentcolor
of the imagelist in the IDE designer. As a workaround, I think we can try
to rebuild the imagelist on the fly everytime we need to change the
transparentcolor.
Here is the code snippet, you may have a try and let me know the result.

<code>

Dim il As ImageList
Private Sub RebuildImageList()
If Not il Is Nothing Then
Me.components.Remove(il)
End If
il.Dispose()
il = Nothing
il = New ImageList
il.ColorDepth = ColorDepth.Depth32Bit
il.ImageSize = New System.Drawing.Size(32, 32)
il.Images.Add(New Bitmap("C:\red.bmp"))
il.Images.Add(New Bitmap("C:\blue.bmp"))
il.Images.Add(New Bitmap("C:\green.bmp"))
Me.components.Add(il)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
components = New System.ComponentModel.Container
il = New ImageList
RebuildImageList()
il.TransparentColor = Color.Blue
For i As Integer = 1 To 12
Me.ListView1.Items.Add(i.ToString(), i Mod 3)
Next
Me.ListView1.LargeImageList = il
End Sub
Shared times As Integer = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim c As Integer = times Mod 3
Select Case c
Case 0
RebuildImageList()
il.TransparentColor = Color.Green
Me.ListView1.LargeImageList = il
Case 1
RebuildImageList()
il.TransparentColor = Color.Red
Me.ListView1.LargeImageList = il
Case 2
RebuildImageList()
il.TransparentColor = Color.Blue
Me.ListView1.LargeImageList = il
End Select
times += 1
End Sub

</code>

Please apply my suggestion above and let me know if it helps resolve your
problem.

However, if the problem still persists, please help me collect more
information for further troubleshooting.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #2
Interesting..
I created a new project as suggested and inserted 3 images into the ImageList. All of them were inserted with the same properties for the Image as I pointed out earlier
PixelFormat=Format8bppIndexed, RawFormat=Bmp, Vert & Horiz Resolution = 71.9836, Transparent Color = Magent
All the Images appear in the list of Images with Magenta backgrounds (not shown with transparent backgrounds like I am used to seeing

However when I create a button and set the ImageList property to ImageList1 and ImageIndex to 0 I get the transparent image showing on the button (technically perfect...) But when I check the properties of the Image from the button control properties. The properties are set to
PixelFormat=Format32bppArgB, RawFormat=MemoryBmp, Vert & Horiz Resolution = 96, Transparent Color = 9

Very strange (at least I think so)

Any thoughts.. Is this the correct behaviour for the ImageList
It seems to be working but it makes me a little nervous

Cheers

David
Nov 20 '05 #3
Hi David,

I have got your reproduce sample, since the bitmap in the imagelist has
been serialized into the resource file, the properties of the bitmap I can
see is PixelFormat=Format32bppArgB, RawFormat=MemoryBmp, Vert & Horiz
Resolution = 96, Transparent Color = 96 just as you have pointed out.

Have you tried checked the original bitmap file properties to see what is
its original properties by following the steps below?
1. browse to the bitmap file(e.g. red.bmp) in the windows explorer
2. right click on the red.bmp file and select properties
3. select the Summary tab and observe the image property(if you did not see
the image property please click the advance button)
4. What is the original Bit Depth of the bitmap file and its size? Did it
fit what you have seen before(PixelFormat=Format8bppIndexed, RawFormat=Bmp,
Vert & Horiz Resolution = 71.9836)?

As for the Image Property will be "PixelFormat=Format32bppArgB,
RawFormat=MemoryBmp, Vert & Horiz Resolution = 96, Transparent Color = 96",
I think the behavior is correct, because if we look into the code in the
InitializeComponent sub which was generated by the IDE designer.
'
'ImageList1
'
Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
Me.ImageList1.ImageStream =
CType(resources.GetObject("ImageList1.ImageStream" ),
System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Green

We will find that the image in the ImageList1 will be retrieve from a
memory stream, so the properties will be MemoryBmp and the size and modify
as we have defined in the imagelist property. The
PixelFormat=Format32bppArgB is to maintain the max available color depth.

So I think we do not need to worry about the RawFormat=MemoryBmp, it will
be handled by the IDE.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
In reviewing everything it appears that your explanation covers off why the format is being morphed to the different format. You are also correct in the original image being the settings that I was getting on the insert.
What is still odd to me is that the transparent color still appears on the image in the ImageList (but not the original 3 images).

My best guess is that the Image List was copied and pasted from a previous form and perhaps this copying of the ImageList is changing the image properties (probably because of the serializing of the images).

In the meantime I guess that we can close this thread as I think it will probably still work fine. I appreciate your input

Cheers

David
Nov 20 '05 #5

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

Similar topics

1
by: SpaceMind | last post by:
Hi, Iīm using this code for changing the size property of an ImageList : ImageList.ImageSize = new Size(32,32); However , the Icon property just lostīs his data. Before code: ...
0
by: MB | last post by:
Hi a guys 02 questions a bout imageList please help me if you have an idea 1) I have a strange probleme with imageList, I added some images at designtime and I can see the images but at...
2
by: Bob C. | last post by:
Hi All, I am using the ImageList/ListView Components to display around 100 images in C#.NET. The issue i have is, some times i may need to display the thumbnail of size more then 256x256 in...
4
by: felix | last post by:
Hi, I tried google and searched the old posts -- with no success. Like a zillion of people before I have a problem when rendering transparent PNGs with GDI+ and the C# Graphics class. The image...
2
by: Sanjeeva Reddy | last post by:
hai Anti Keskinen, i have used the following code MyListView->LargeImageList->ImageSize = gcnew System::Drawing::Size(100, 100); // Sets large image size to 100, 100 here i am getting error...
0
by: David | last post by:
I have a problem that just cropped up with using an ImageList in my project I am using VB .NET 200 Problem: I have existing Form with 2 Image List controls. ImageList16 (for 16x16 Images) and...
0
by: Andre Viens | last post by:
Hello, I am using the following variation of code from <http://support.microsoft.com/default.aspx?scid=kb;EN-US;319340> to add icons to an imagelist for use in a listview: Private Structure...
4
by: Archimed | last post by:
Hi, I try to use an ImageList with a ListView but that don't work. I make a ListView in VirtualMode with LargeIcon view. I put the ImageList in the LargeImageList property. I add a bitmap...
0
by: wolffy | last post by:
okay heres my problem; i want to add image K to a imagelist, thats easy. The hard part is that the imagelist was made in Application Settings. **I made the imagelist in application settings so i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.