i have an image list, i am drawing it on form list-control.
i will get image bounds when the images gets added to list.
and it will come to draw-event there i get bounds.
instead how to get the bounds width and height at form-load.. i mean before drawing.
how to calculate it?.
i am using .net3.5 CF framework
Assuming you are using a list view control and the imagelist property then you can use
ListView.ImageList.ImageSize, although I don't think that this changes automatically depending on the images you add, docs suggest it defaults to 16x16, so you will have to set it I guess.
You don't say how you are loading the images, do you set the imagelist items at design time? Or do you load them from files at runtime? If you load them at runtime you can get the image size info from the file as you load it.
Related
The Forms DataPoint class contains a property for setting the path to an image used as the background for the DataPoint. I obtain an image from an internal symbol provider and it seems wasteful to have to write the image to a file before using it. I looked at deriving from DataPoint but there doesn't seem to be anything relevant I can override. Any suggestions for setting the DataPoint background to the image directly?
It turns out that the base Chart class has an Images property, this can be populated with images without needing to write them to file first.
The images can then be set to the MarkerImage property of DataPoint.
http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.chart.images%28v=vs.110%29.aspx
Alright guys last little bit of this project I'll ask for help on I promise.
So I go to load the images, works fine however I notice upon loading that the dimensions of the image have been scaled down in the y to 300 (all are a constant value of 433) and up or down from their original width to 600.
I'm using the following method to load them
foreach (string file in Directory.EnumerateFiles(imagePath, "*.JPG"))
{
Image contents = Image.FromFile(file);
treesImage[count] = contents;
count++;
}
and this is the resulting image when I have it loaded.
http://i.stack.imgur.com/Q40kK.png
As you can see the image below the red rectangle is quite small
Any help would be appreciated. If you require any more information please post below and I'll make sure to edit the original question with the relevant information as soon as humanly possible.
EDIT: I am using a simple windows form application and not another graphical framework for my own reasons.
Thanks in advance :)
I'll assume you are using a PictureBox control to display the image.
When someone chooses a tree from your map, you obviously set the PictureBox Image property to the image object referenced by the index in the array. Use the Image object to set the ClientSize of the PictureBox control.
...
Image img = treesImage[idx];
MyPictureBox.SizeMode = PictureBoxSizeMode.Normal;
MyPictureBox.ClientSize = new Size(img.Width,img.Height);
MyPictureBox.Image = img;
...
Alternately you can define one size for your PictureBox and force all the images to be scaled to that size by setting the control SizeMode property to StretchImage declaratively.
I would recommend that you create a simple class (MyImageInfo for example) that would store the Path, Width, and Height of the images found in your first function into a list and then just as before when a user clicks to view an image you set the width and height of the PictureBox and then call the LoadAsync(path) method to get the image. then you aren't storing all images in memory at once, just as you need them since it doesn't look like this requires a lot of quick jumping from image to image.
I would like to know how I can create one image from many. I would like to create a tile in my windows phone application like in this image (specifically, the People tile):
(source: addictivetips.com)
I have nine pictures, and I would create an image, that I will add like tile to background. Does anybody know how can I create an image that looks like the one in that picture?
I have very little experience in this space, but have you considered creating a control that simply displays up to 9 pictures side by side in a grid like that? You then can bind each image independently & change them out however you want. This article touches on how to bind phontos in WP7 nicely:
http://msdn.microsoft.com/en-us/library/hh286418(v=vs.92).aspx
If you're talking about assembling an actual graphic image like a jpeg or bitmap, you'll need to look at the Image Class, Bitmap Class, and Graphics Class. Essentially you'll need to implement the following steps:
Load the relevant images with From method in Image, typically Image.FromFile.
Determine how many rows and columns you'll be using.
Calculate the total width and height for your layout using the widths and heights of the loaded images with appropriate padding added.
Create a new Bitmap of the appropriate size with the correct background color and iamge format.
Have variables for the current drawing location (x & y).
Have variables for the current row and column in your layout.
In a loop, Create your Graphics object.
Use Graphics.DrawImage to add your loaded image to the layout bitmap.
Increment your drawing row and or column as appropriate.
Calculate your new drawing location.
Repeat until done.
One of the options is to use WriteableBitmapEx
Also you can probably find an answer to your question here: How can I merge two images into one?
I have a form with two buttons.
To one of them I assigned an image (a 16 x 16, 32 bit depth png) by setting the Image property from VS's properties editor (using the Import... button).
I also have an ImageList (16 x 16 ImageSize and Depth32Bit ColorDepth) to which I assigned the same image as to the first button also from the properties editor -> Images and then Add. Then I assigned this image to my second button this way:
button2.Image = imageList.Images[0];
And this is how the images look (2x the actual size):
Is it possible to have my second button look like my first one by using an ImageList? The reason why I use an ImageList is because when checking performance, the line of code that loaded the image from the resource was a hot spot according to VS's Performance Wizard.
My application will have a list of controls, each of which have a bunch of buttons with images, so I want them to load as fast as possible. So what I have is a static ImageList from which each of these controls get their images.
This is because the images you have added in your Imagelist have higher ColorDepth that the ColorDepth you have set in your ImageList Properties. for example, if the images you have added are in PNG format, you should set the ColorDepth of you ImageList (In the properties window) to Depth32Bit as the PNG format uses 32Bit color depth.
I'm attempting to display a "LargeIcon" view in a listview control, however the images I specify are blurry. This is what I have so far:
alt text http://img220.imageshack.us/img220/1005/blurryiconsql3.jpg
The .png files are 48x48 and that's what I have it set to display at in the ImageList properties. There's one thing that I've noticed (which is probably the cause) but I don't know how to change it. Inside the "Images Collection Editor" where you choose what images you want for the ImageList control, it looks like it's setting the wrong size for each image.
alt text http://img83.imageshack.us/img83/5218/imagepropertiesmf9.jpg
As you can see the "PhysicalDimension" and the "Size" is set to 16x16 and not abled to be manipulated. Does anyone have any ideas? Many thanks!
Be sure to set ImageList.ImageSize to 48 x 48 too.
When adding a .PNG Icon format size the editor tends to pick the first entry size in that file, so it picks up the 16x16 entry and it's stretching that out. That's why you see the 16x16 in the properties there. As suggested, the support for PNG is poor, I'm often found myself rolling over to another format as well to avoid this.
You can open the file in Paint.Net if you need a free editor or something more fully featured like Photoshop or Fireworks and extract the exact size you want.
I'm not sure if its the problem in this specific case, but Microsoft support for the PNG format is generally poor. Try adding the images in .bmp format and they should display fine.
Check also the ColorDepth setting on your ImageList. I had a similar issue with a TreeView control, but after reading the previous posting regarding the size I found this setting, played around with it a bit and found that it greatly affects the way images from an ImageList are rendered. The higher the depth the better the quality.
Be sure to set the ImageList size to 48x48 px BEFORE you add the images.
If the ImageList is set to 32x32 and you add a 48x48 image, the icon is resized to 32x32. When you change the ImageList to 48x48 afterwards, the image is just resized again, thus losing quality and going blurry.
Also, Paint.NET (or Photoshop) can't open .ico files.
Visual Studio/.NET can handle 32-bit PNG images fine, the built-in image editor in VS is a bit lack-lustre though.