 |
|
 |
Hi...thanks for the nice control
But I found bug when the filmstripcontrol load the sample image in windows 7 (C:\Users\Public\Pictures\Sample Pictures)
The image that showed in filmstripcontrol is not so clear
string[] filePaths = Directory.GetFiles(@"C:\Users\Public\Pictures\Sample Pictures\");
foreach (string file in filePaths)
{
if (Util.IsValidImageExtension(file))
{
filmstripControl1.AddImage(new FilmstripImage(Image.FromFile(file), ""));
}
}
could you help me?
modified 10 hrs ago.
|
|
|
|
 |
|
 |
Hi, I am using FilmStripControl together with Emgu. A very particular has been frustrating me for weeks. I have no problem adding image from Emgu ImageBox to FilmStripControl. However, what is strange, is that the last image replaces all previous images, so all thumbnails are showing the last image. I suspect something to do with Ptr, but I am unsure how to resolve it.
Below is the code I have been trying. It starts the image capturing in Emgu. Clicking on the same button only takes a snapshot and add to FilmStripControl.
private void pbCapture_Click(object sender, EventArgs e)
{
#region if capture is not created, create it now
if (_capture == null)
{
try
{
_capture = new Capture();
}
catch (NullReferenceException ex)
{
MessageBox.Show(ex.Message);
}
}
#endregion
if (_capture != null)
{
if (_captureInProgress)
{ //stop the capture
_imgCount += 1;
string strCount = _imgCount.ToString();
ibCaptureImage.Visible=false;
fscThumbnails.AddImage(ibCaptureImage.DisplayedImage.Bitmap,strCount);
ibCaptureImage.Visible=true;
}
else
{
//start the capture
this.btnSnapDocument.Text = "Stop";
Application.Idle += ProcessFrame;
_captureInProgress = !_captureInProgress;
}
}
}
|
|
|
|
 |
|
 |
Hi
Whilst I am not familiar with Emgu capture component, I think I may know what is happening.
The Filmstrip control assumes that each Image added is a unique object. I think what is happening is that the Emgu Capture object re-uses the same Image object for every image taken - so each image added to the Filmstrip control is actually just a reference to the same Image object that has had its contents changed. Hence why all thumbs show the last image captured.
What I think you need to do is either:
1. Save each captured image to disk, and then create a new Image object from the saved file to add to the Filmstrip control.
or
2. Clone the image from the capture object before adding it to the control.
Bear in mind that I have not tested either of these ideas, they are just my best guess at the moment. I hope it solves your problem though.
Mike
|
|
|
|
 |
|
 |
i have a question about viewing images that are stored in a sql table, can you control do this?
|
|
|
|
 |
|
 |
Hi
The control works with Image objects only. If you have images stored in a SQL database then these would first need to be extracted into Image objects before they could be passed to the control.
Mike
|
|
|
|
 |
|
 |
Is it possible to add a resource from my project? I'm new to C# and I want to add this to my filmstrip:
global::myProject.Properties.Resources.projectIcon;
How do I do that?
|
|
|
|
 |
|
 |
Sure. You just need to use the appropriate AddImage overload, as described in the Quick Start section above.
For example:
filmstripControl.AddImage(Properties.Resources.projectIcon as Image, "The project icon");
There is also a good example in the test application - in the form class there is the method, AddDefaultImages() which adds a number of images in the project resources to the control.
Mike
|
|
|
|
 |
|
 |
First of all, I'd like to express my sincere "thanks" for this control creator. Great control and exactly what I was looking for... Best on the net.
Ok. However, here is question/problem that I have. I modified the "Double Click" event for the selected image to start an external image editing tool such as "PaintDotNet.exe" so that I can modify the image. However, as you can predict, I get an error message saying "... the file is being used by another process..." which is completely understandable. So, I tried to come up with a way to release the resource by calling a few methods available in control, for example, ClearAll, RemoveImage, ClearSelection, etc... but it's not working for me. Can anyone help me to understand what's need to make this work? or even if it's possible or not?
Thanks in advance.
|
|
|
|
 |
|
 |
How did you add the image to the control? If you used the Image.FromFile() method then there is a known issue with this method.
For the time being please refer to Geepster's comments below on how to avoid file-related exceptions.
I am going to look into seeing what I can add to the control to make the whole process easier when adding file-based images.
Mike
|
|
|
|
 |
|
 |
Thanks!
Looking forward to hearing back your solution!
|
|
|
|
 |
|
 |
In the example code, the description field has an 'Update' button. Wouldn't it be better to just have edits of the description field automatically take effect? The obvious approach is to add a text-changed handler, along the lines:
private void textSelectedDesc_TextChanged(object sender, EventArgs e)
{
if (filmstripControl.SelectedImageID == FilmstripControl.NO_SELECTION_ID)
return;
filmstripControl.SelectedImageDescription = textSelectedDesc.Text; // We // Probably don }
Well, the obvious approach causes problems (which is probably why the Update button was used in the first place), because there's another handler called as a result of the user changing the selected image, UpdateSelectedInfo(), and the result is potentially an endless cascade of events. But an alternative fix for that is to introduce a boolean, that will effectively differentiation changes to the description field due to user typing versus image selection change:
private bool ignoreDescTextChangedEvent = false;
private void UpdateSelectedInfo()
{
ignoreDescTextChangedEvent = true;
textSelectedDesc.Text = filmstripControl.SelectedImageDescription;
ignoreDescTextChangedEvent = false;
SetButtonStates();
}
private void textSelectedDesc_TextChanged(object sender, EventArgs e)
{
if (ignoreDescTextChangedEvent)
return; // prevent endless loop when selected image changes
... remainder is as shown above ...
Actually, my real code is a bit more complex than this, in that in the second handler I squirrel away a copy of the updated description into my own data structure. I do this so I can retrieve the description of any image I want, without having the GUI implications of having to select each image in turn.
This suggests the desirability of additional control methods, e.g., GetDesc(int filmstripID) and SetDesc(int filmstripID).)
|
|
|
|
 |
|
 |
Thanks for your comments.
I understand what you're saying about the demonstration application, but it was created to be just that and not fully featured production quality code.
That said, I full agree with you about the need for public methods to get and set the description of any image in the collection. These methods will be included in the next version.
Mike
|
|
|
|
 |
|
 |
The test example uses images contained as resources, but if you get your images from the file system, other issues can arise.
What I tried first was:
private int AddToFilmstrip(string pixfile)
{
int n = filmstripControl.AddImage(new FilmstripImage(Image.FromFile(pixfile), ""));
SetButtonStates();
return n;
}
Regrettably, this locks the file from now until the end of time (or at least until your app exits), making any reasonable "Delete Photo" functionality impossible - it'll throw a file-locked exception. Turns out this is a known problem with Image.FromFile() [MS Article ID 311754].
OK, next:
private int AddToFilmstrip(string pixfile)
{
Stream fs = new FileStream(pixfile, FileMode.Open, FileAccess.Read);
int n = filmstripControl.AddImage(new FilmstripImage(System.Drawing.Image.FromStream(fs), ""));
fs.Close();
SetButtonStates();
return n;
}
This almost works, but whenever the image selection is changed, an "out of memory" error is thrown, presumably because the control is trying to redraw the big image using the now-closed filestream handle.
Instead, you have to do the appropriate fs.Close() later, when an image is deleted. Consequently, the filestream in the AddToFilmstip() has to be remembered in some data structure that seconds the images. I use a List of homemade objects (I'll call them MyData here), so the function becomes:
MyData myData = new MyData();
myData.FilePathAndName = ....
AddToFilmstrip(myData);
MyDataList.Add(myData);
....
private void AddToFilmstrip(MyData md) // md.FilePathAndName is set when this is called.
{
md.fileStream = new FileStream(md.FilePathAndName, FileMode.Open, FileAccess.Read);
md.filmstripID = filmstripControl.AddImage(new FilmstripImage(System.Drawing.Image.FromStream(md.fileStream), ""));
SetButtonStates();
return;
}
Then later, as each image is deleted:
md.fileStream.Close();
You have to manage MyDataList throughout... an exercise for the reader.
|
|
|
|
 |
|
 |
Thanks for these good comments. Whilst I have yet to test the problem, the fact that 2 people have encountered it is enough for me to see what I can do about it.
Watch this space...
Mike
|
|
|
|
 |
|
 |
I just want to say congratulations and thank you for sharing this ... I been looking for a control like this, great job !
|
|
|
|
 |
|
 |
Both main and thumbnail image scalings are way off when the Filmstrip is placed on a tab control page. Any chance you've tried that?
|
|
|
|
 |
|
 |
Thanks for the feedback.
I hadn't tried using the control on a tab page before you posted. But since then I have tried and tested it and found no problems at all. What is the problem exactly?
Could it also be that you are using a different set up to me. Currently I am using VS 2005 Express on WinXP using .Net 2.0. I have not tested it on any later versions (VS 2008, Vista, .Net 3.0 or later, etc.) so I cannot verify how well it may or may not work. Sorry I cannot be of any more immediate help.
Mike
|
|
|
|
 |
|
 |
I'm also seeing this problem on a tabbed control, although I don't know that it's specific to tabs. If you make the control about 75% smaller than the default size, it seems like the scaling of the image in the main image area doesn't realize that the area is smaller, so puts up the image (with "Center" mode specified) in such a way that it is offset horizontally and clipped at bottom and right edges.
BTW, the thumbnails are shown as squares, with vertical image stretching, rather than with the original 3:4 aspect ratio.
This is in VS 2005 Pro, WinXP, .Net 2.0
I tried putting a groupbox around the control, as in your test app, but that made no difference.
|
|
|
|
 |
|
 |
Also, the control's BackgroundImage property does not seem to work, that is, nothing is displayed in the background of the main image area.
|
|
|
|
 |
|
 |
Oh, the workaround on that last item is set the .ControlBackground color to transparent, and then you can see the background image, which is evidently painted over by the background color.
|
|
|
|
 |
|
 |
Glad you found a workaround.
This is because the control background is completely covered by the main image control and the panel containing the navigation strip. The property did not feature in my original design for the control and should really be hidden or marked as obsolete as it is no longer in use.
Mike
|
|
|
|
 |
|
 |
I'll be using it to put up an attractive background image that includes some text phrase such as "No photos yet". I'll photoshop it so that the part behind the filmstrip is a uniform color.
- G
|
|
|
|
 |
|
 |
I am still having problems reproducing this sizing issue. Do you have any sample code I can try?
Thumbnail images: These images appear stretched because the I am using the 'Image' property of the Button class which does not have a corresponding 'ImageLayout' property. The control could easily be changed to use the 'BackgroundImage' property instead, but this would also mean that the thumbnail creation routine would also need modifying so that the thumbs generated were sized correctly.
At present I do not have the time to test and update the code, but I will try to get to it when I can.
Mike
|
|
|
|
 |
|
 |
Thanks, Mike. I'll try to build a concise sample I can send to you... probably next week at earliest, since I've got a presentation coming up shortly on another project.
RE thumbnail images: You're proposing using a BackgroundImage property of the button class? Or of the filmstripControl class... would that mean I'd lose the means to set my main background image?
In the writeup's example image, the main and thumbnails photos all are shown with a 4:3 ratio. Was that done by compositing the photos in advance into a square image format with blank bars above and below? Or just reflects an earlier implementation?
- G
|
|
|
|
 |
|
 |
Hi!
First of all it's a nice work, but I have some some criticism.
1. Why do you force the user (I mean the programmer) to define id values? Completely unnecessary and makes need to keep track of the IDs already used - it's typically something you should handle internally. (And why on earth was 0 not a valid value? I took me quite a time to figure out why AddImage thrown an ArgumentRangeException)
2. Suggestion: Use a flowlayoutpanel to do the layout of the items, it will also provide a scrolling feature.
And thank you for your work. You saved some workhours to me
Tomi
|
|
|
|
 |