Problem with Images on TreeView - c#

I have a TreeView with ItemHeight=16 and CheckBoxes=true. I want to show images that are 8x16 pixels in size on the nodes. But when I do this, the "Plus/Minus" and "CheckBoxes" change their size (get smaller).
How can I fix this? I don't want to use a 16x16 image because I don't want to loose those 8 pixels with white space.
Any suggestions?

That sounds like a bug. Checkbox size and plus/minus size shouldn't be affected by the image size. Check with MS and see if they have a solution.

Have you tried TreeViewAdv for .Net it comes with huge amounts of awesome, and should solve your problem...

Related

RibbonToggleButton displays image badly

I'm using Ribbon from RibbonControlsLibrary.dll 4.0.0.11019, .NET 4.0, C#, WPF.
It can be downloaded with a free samples here: http://www.microsoft.com/en-us/download/details.aspx?id=11877
The problem comes when a RibbonToggleButton is displayed. Then it's image seems to be a little bit broken, like a part of image is shifted for a few pixels.
EDIT: Thanks to kind people I can post and image now:
Here are some details:
Image is displayed in it's large variant
Image size is 32x32
I set image scaling to none for all the images of Ribbon
Image is broken only when the text in RibbonToggleButton has 1 line
Same image displays correctly in any other kind of button (RibbonButton, RibbonSplitButton etc.)
The image is displayed correctly when I set the font size in Windows to Medium (125%)
My OS is Windows 8
When I set the VerticalContentAlignment for the toggle button to "Bottom", the Image starts to display correctly, but the whole Ribbon starts to look ugly.
I experience this problem for all the toggle buttons, including those which are in a Microsoft's free samples.
I guess that probably the Image doesn't have enough space, so it's compressed from 32x32 to some smaller size.
I use the theme that is made of Microsoft's Generic theme, that is included in the RibbonControlsLibrary.dll. I guess I could fix the RibbonToggleButton template somehow, but I have no idea what to fix there.
Any ideas?
In the xaml declaration of your UserControl / Window put that line:
RenderOptions.BitmapScalingMode="HighQuality"

Bitmaps in WPF - give watermarking effect and then recover images individually

I am working on a project where I need to play with two bitmaps. I am putting them in a grid one over the other with reduced opacity (to give a watermark effect).
I am rendering the grid to a bitmap using RenderTargetBitmap and saving the bitmap to a file.
Now my requirement is to load the rendered bitmap again and recover the original pictures separately. Is there any way to recover the original images again. I am not able to think any algorithm to implement this.
My aim is to give a watermarking effect and then recover the images individually.
No. The information is lost during "flattening" of the image.
You need to save both images and information about their properties (position, opacity) into single file. And restore it on load.
If your goal is to simulate watermarking and allow later 'dewatermarking', then assuming that you have your watermarking bitmap present at decoding time, you probably can do that. Sure you cannot use your initial approach - just simple merging of two layers is not reversible.
You need to use some reversible transformation, like rotating source image pixel RGB values vector, using watermark image pixel RGB values as parameters. While dewatermarking you just use negative values from watermark image.
Well, RGB vector is not ideal - you can go out of RGB space while rotating it. Probably you can find color space (or some other transformation in RGB space), better suited to your goal.
(English is not my first or even second language, thereby I apologize if you can't understand my idea - just ask over.)
Why don't you try to make it two layers of bitmap?
i wonder if you can use TIFF format, where you can store multiple images. that way on display you can choose to show with/without watermark.

C# - Image comparison (fast one)

At the moment I've got an database with over 100.000 images, they ain't the same size or anything like that but I want to make the following for my compagny:
I insert/upload an image and the system returns the image which is most likely the same. I don't know what algorithm to use but it needs to be fast. I can pre-process all the other images and put some info in the database which I use for the comparison.
Now what I want to know what the fastest way is to compare the images (with a good chance of being the same image). And what data I should save into the database (I could probably figure this one out myself if I got the algorithm).
It shouldn't take more then 5 minutes to compare the uploaded image to all the images in the database.
Thanks in advance!
Julian
Look at www.tineye.com, they have some kind of algorithm that I'm looking for. Guessing they use a very complex one, I just need one that does same thing but with lesser rate of succes.
The way I would do it is I'd generate a really small (say.. 1/50 of the original image size) image from every image you're comparing against, and store the thumbnail image path along with the original size in the database. I'd keep the thumbnails as uncompressed bmp's for speed and loss-free-ness (I just made that word up!), since they're so small anyway.
To compare your new image against the other ones, shrink it down by the same amount and compare it against the others pixel by pixel, with a certain threshold (say.. 10% difference from the original).
If it passes this test, you can do a full blown pixel by pixel compare against the original image.
edit: I just want to mention that I went down the probabilistic way before too. It worked OK, but building the meta data for the images took forever, and there were a lot of false positives. Instinctively, I think that calculating local averages for each grid rectangle of your image (which is what shrinking your image down does) would give similar, if not better results.
The best way for comparison is convert image to gray scale format and compare intensity of gray color. Its the fastest way used in real-time systems.
Also if you want to achieve higher qaullity and use colored images - use CIE 1994 or CIE 2000 as color difference formula

Compare images in C# .NET

I have a scanned image of a document which has multiple boxes which may or may not contain signatures. I am able to identify the boxes, but now I want to figure out which boxes contain signatures. I tried to compare the image with the reference blank box image. Ideally pixel match should do,but my images can be tilted by some angle, which makes it tough. I am programming in .NET.
Any suggestions?
Edited on Jan 04:
I have asked this question on Nov 25. At that time, the solution proposed was to check count the number of black pixels in the image. That worked for me. However, the performance of the application is bad now. Because, it has to check black pixels on 20 rectangles of 100*1000 size.
Is there any better to solution to determine if a image is blank?
Perhaps you could sum the number of pixels matching the 'blank' colour, and then sum the number of pixels not matching the blank colour. If the number of non-blank pixels is over a certain level, then assume that there is a signature? Logically, an empty box will contain almost entirely blank pixels, and a box with a signature in it will contain a lot less blank pixels.
Edit: One extra point - you will want to have a degree of tolerance for what is a 'blank' pixel colour, otherwise a bit of dust or gradient that arose while scanning will cause a non-blank pixel.
You should try to normalise the rotation of the images first. One way to do this is to place markers on the page which can be lined up (a black square in each corner of the page is what I have seen used before) to ensure that the page's rotation is correct before you try to identify the signatures.
Maybe the quickest way is to perform an MD5 Hash on the byte stream of the image and compare the results? Look here for further info on this.
Hope this helps,
Best regards,
Tom.

Listview icons show up blurry (C#)

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.

Categories

Resources