|
Hi, its me again, the n00b.
Last week i was doing a Image Explorer which manages around 1000 images per folder, its working fine and now i did ListView which shows it in large icon mode, the problem was when I tried to show the images, i resized the image, indexed it inside an image list and point the listviewitem to it. Ok then it works but its just slow, very slow, next step i did its to thumbnalize images to 96x96 and save them in a JPG to do a fast load without resize thinking that it will solve the problem. But it was slow like the other method, then I put a thread who gets a Queue of images to add into ImageList, but from my point of view it continues being slow. And then i thought maybe i need to ask ppl who knows better the .Net to show me wats the best way to load from HDD images into an image list.
Summary,
Im filling ListView pointing to a ImageList with a "Loading Image" Index 0, and put the images to load in a queue, then the other Thread gets the list and loads image doing some like:
Image = Image.FromFile( the file ); ImageList.Images.Add( Image ); And place the new Index into ListView...
Like i said, it works, but slow,
Somebody can give me some advice ?
Thanx in advance,
|
|
|
|
|
Hi, maybe you are running out of physical memory: loading a lot of images will soon cause Windows to fill all physical memory, and then to swap the images to disk again, which
is not only pointless but also often terribly slow.
When dealing with hundreds of images, make sure to only load thumbnail images, not entire images.
Furthermore, you may have to create small thumbnail files rather than trying to read them
from the original image files. The Image classes keep their files open (I guess to keep the
image properties available) for as long as the image object lives, hence consuming tons
of memory.
Or you may try the following: in one of my applications after reading an image from file,
I immediately copied the image into a new bitmap (see code snippet below), allowing
the gc to retrieve the original Image object immediately, just to avoid the file remaining open and a lot of memory being used.
Maybe you can do something similar ?
public Bitmap ReadImage(string fileSpec) {
FileStream stream=File.OpenRead(fileSpec);
Image image1=Image.FromStream(stream);
Bitmap image2=new Bitmap(image1);
stream.Close();
image1.Dispose();
return image2;
}
-- modified at 15:20 Monday 4th December, 2006
Luc Pattyn
|
|
|
|
|
mmmm, its faster but... like you said i have the images at disk thumbnalize 3kbytes per image at 32bits jpeg, also i put the imagelist in the same pixelformat, etc... and thats a simply loop that tooks 40-45secs loading 500images, memory its going to 48MB think is not the problem...
<br />
foreach (StockFile sfile in sf.Files)<br />
{<br />
string[] strItems = { sfile.FileName, sfile.Name };<br />
<br />
if ( File.Exists( sfile.SmallThumbFileName ) && indexItem<500 ) {<br />
<br />
FileStream stream = File.OpenRead(sfile.SmallThumbFileName);<br />
Image image1 = Image.FromStream(stream);<br />
ThumbWithFrame = new Bitmap(image1);<br />
stream.Close();<br />
image1.Dispose();<br />
fvImageList.Images.Add(ThumbWithFrame);<br />
<br />
lvFiles.Items.Add( new ListViewItem(strItems, fvImageList.Images.Count-1 ) );<br />
} else {<br />
DCRQueue dq = new DCRQueue();<br />
dq.sfile = sfile;<br />
dq.li = lvFiles.Items.Add( new ListViewItem(strItems, 0) );<br />
Thumbs2Do.Enqueue( dq );<br />
}<br />
<br />
indexItem++;<br />
}<br />
|
|
|
|
|
Hi Marcos,
I would suggest to temporarily remove the second halve of your for loop,
so you can observe the loading of the files, without the ListView and DCRQueue operations,
just to figure out which part is taking so long.
Is your ListView visible while your code executes ? maybe it recalculates everything
after adding each individual image, which I guess is not what you really need.
If so, you want to use a single AddRange outside the for loop instead of n times Add.
Alternatively, you may want to call SuspendLayout() and ResumeLayout() before/after the
for loop.
greetings,
Luc Pattyn
|
|
|
|
|
Think your are right right right, the problem is at ListView.Add... refatoring time...
Thanx for your time,
|
|
|
|
|
i just create one database it's:
create table HANGHOA
(
MAHANG varchar(9) not null,
TENHANG nvarchar(50) not null,
DVDOLUONG nvarchar(15) not null,
DINHLUONG int not null,
DONVI nvarchar(15) not null,
MOTA nvarchar(50) null ,
TONKHO int null ,
DGBAN int null ,
CANDUOI int null ,
constraint PK_HANGHOA primary key (MAHANG)
)
When i created datagrid and add TENHANG to col1 :
private void CreateDataGridStyle()
{
this.dataGrid1.ReadOnly=true;
DGStyle = new DataGridTableStyle();
DGStyle.MappingName ="HANGHOA";
col1 = new DataGridTextBoxColumn();
col1.MappingName ="TENHANG";
col1.HeaderText = "TH";
col1.Width = 90;
}
but now i want to create table TH with three MappingName : "HANGHOA";"DVDOLUONG";"DINHLUONG" to one.
Because when i create datagrid it's have 3 column but now i want to view it's one.
private void CreateDataGridStyle()
{
this.dataGrid1.ReadOnly=true;
DGStyle = new DataGridTableStyle();
DGStyle.MappingName ="HANGHOA"+"DINHLUONG"+"DVDOLUONG";
col1 = new DataGridTextBoxColumn();
col1.MappingName ="TENHANG";
col1.HeaderText = "TH";
col1.Width = 90;
}
ex: table first is
HANGHOA DVDOLUONG DINHLUONG
abc 1 st
but end is
"TableMapping"
abc is 1st
i said may be you can't understand but may be my "ex:" be you see the problem!
Thanks !!!Please Help me!
|
|
|
|
|
3. Keep the subject line brief, but descriptive. eg "File Serialization problem"
Please Help me!!!Thanks !!! may be brief but hardly descriptive.
only two letters away from being an asset
|
|
|
|
|
Your line:
DGStyle.MappingName ="HANGHOA"+"DINHLUONG"+"DVDOLUONG";
is equivalent to:
DGStyle.MappingName ="HANGHOADINHLUONGDVDOLUONG";
As there is no field by that name, it won't work.
You have to concatenate the values when you query the data from the database, not when you specify your data grid.
---
b { font-weight: normal; }
|
|
|
|
|
how can i add a autofilters like dropdownlist to a datagrid header ,and when
user selects one item from dropdownlist datagrid values must be updated.
thanks
mahesh.nalla
|
|
|
|
|
I am trying to pass an array of strings from C# to the .NET component
I created in Matlab. I am getting a compile time error in Visual
Studio telling me that it can't convert a string array to a MWArray.
I have tried performing explicit conversions, but none of them work.
Any help would be greatly appreciated.
Here is an example of what I am trying to do:
[C#]
using MathWorks.MATLAB.NET.Arrays;
using MyMatlabNet;
...
MyMatlabNetClass myclass = new MyMatlabNetClass();
...
string [] mydata;
myclass.somemethod(mydata);
I have tried (MWArray), (MWCharArray), (MWCellArray) and nothing
works (allows it to compile).
|
|
|
|
|
Hello all... If you had a parent object and wanted to expose its children from persistent storage, would you do it by exposing the children as if the parent was a List or just a few methods for getting the count and a range of child objects... or is there another method I might not be aware of.
The children must be editable and retain their data in persistent storage. There could be thousands of children as well.
Secondly, if you were to have a function that did something like "Take money from parent and give to child" would you put this function on the parent, child or as a static function?
|
|
|
|
|
If you are using .NET 2, then I would look at generic collections to store your items:
public class Parent
{
List<Child> _children = new List<Child>();
public int Add(Child value)
{
_children.Add(value);
}
public void LoadAll()
{
}
public void Save()
{
foreach (Child child in _children)
{
child.Save();
}
}
}
public class Child
{
public void Save()
{
}
public static Child Fill(IDataRecord row)
{
Child child = new Child();
child.Id = Convert.ToInt32(row["Id"].ToString());
return child;
}
}
This is just a sample of the type of approach you might take. It isn't intended to be directly coded from.
-- modified at 4:37 Tuesday 5th December, 2006
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi, I want to display 2 pages with different data when i do the printpreview. I created two document objects with a single printPreviewDialog object and assigned each document object but it display only one doucment page. Can some body help me how to solve this issue.
Thanks
PrintDocument pd1 = new PrintDocument();
PrintDocument pd2 = new PrintDocument();
PrintPreviewDialog ppd1 = new PrintPreviewDialog();
ppd1.Document = pd1;
ppd1.Document = pd2;
ppd1.ShowDialog();
|
|
|
|
|
To print two or more pages -even if they contain different data-, you should ruse a single PrintDocument object. In the PrintDocument.PrintPage event set e.HasMorePages = true , until you print al the data you want.
Revise the C# articles - printing section[^] for more details.
Regards
|
|
|
|
|
Great it works for me thanks
|
|
|
|
|
Since Redim does not exist in C#, How do I convert this in C#?
Dim basePoints() As Double
ReDim basePoints(AUTO_PTS - 1, 1)
|
|
|
|
|
Use one of the Collection classes which is designed for better array handling. Take a look at classes like the ArrayList to see how they help.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
There is no equivalent. You can do it yourself with something like this (unchecked, but you get the idea):
double[] NewBasePoints = new double[newsize + 1];
if (thisArray != null)
System.Array.Copy(thisArray, NewBasePoints, System.Math.Min(thisArray.Length, NewBasePoints.Length));
BasePoints = NewBasePoints;
|
|
|
|
|
You're thinking of 'ReDim Preserve'.
The OP was dealing with the simpler 'ReDim'.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: VB to Python converter
|
|
|
|
|
(via Instant C#)
double[] basePoints = null;
basePoints = new double[AUTO_PTS,2];
ReDim Preserve is a little trickier, but also has a C# equivalent.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: VB to Python converter
|
|
|
|
|
Hi All,
I'm trying to create a resizable form with a little bit of auto layout.
Basically I have 7 square buttons grouped into a panel. These buttons must never be split up with any auto layout code.
To the right of the buttons I have a trackbar control. I want the trackbar to grow and shrink as the window gets wider/narrower, but, when the shrinkage would result in the trackbar being below a minimum size (in fact, the width of the button containing panel), i want it to drop to below the buttons.
This image shows my controls - here
Can this be easily done with built in winforms stuff? or must I implement it the long way with various resize event handlers and manual repositioning code? I'm hoping to leverage AutoLayoutPanel - because I will have other controls on the form too, eventually.
Thanks
Jon
|
|
|
|
|
Will this[^] article (EZ layout mgr) help?
/ravi
|
|
|
|
|
Check out the FlowLayoutPanel control. It dynamically adjusts the controls within it to fit, and as long as you group things using panels/groupboxes/etc, they'll stay together.
|
|
|
|
|
What's deal with
treeView1.Nodes.Reverse
'System.Windows.Forms.TreeNodeCollection' does not contain a definition for 'Reverse'
What's the trick to reverse enum a treeview?
Thanks
|
|
|
|
|
er, iterate through the collection backwards?
|
|
|
|