Click here to Skip to main content
15,906,094 members
Home / Discussions / C#
   

C#

 
Generaltoolbar icon Pin
elena1234510-May-04 6:16
elena1234510-May-04 6:16 
GeneralRe: toolbar icon Pin
Heath Stewart10-May-04 6:49
protectorHeath Stewart10-May-04 6:49 
GeneralRe: toolbar icon Pin
elena1234510-May-04 10:08
elena1234510-May-04 10:08 
GeneralRe: toolbar icon Pin
Heath Stewart10-May-04 10:44
protectorHeath Stewart10-May-04 10:44 
GeneralDatabase Wrapper Pin
JohnMess10-May-04 5:25
sussJohnMess10-May-04 5:25 
GeneralRe: Database Wrapper Pin
Heath Stewart10-May-04 5:40
protectorHeath Stewart10-May-04 5:40 
GeneralRe: Database Wrapper Pin
johnmess10-May-04 6:31
sussjohnmess10-May-04 6:31 
QuestionImage retrieval from ImageList is slow? Pin
Judah Gabriel Himango10-May-04 4:39
sponsorJudah Gabriel Himango10-May-04 4:39 
I have a custom control that draws text and images. The images are drawn for each item from a single ImageList:

MyControl control = new MyControl();
control.ImageList = this.imageList1;


In the drawing code, I have something like this:

protected override OnPaint(PaintEventArgs pe)
{
   pe.Graphics.DrawImage(this.ImageList.Images[0]);
  
   // draw a 10-15 other small images 
   ...
}


This is butt-slow! The paint event seriously slows down the entire app everytime I draw. Running it through a profiler tells me accessing the image out of the image list is the culprit (?). And indeed it is; if I store a reference to the image to draw (instead of getting the image out of the image list), it's super fast:

private Image imageToDraw = null;
public MyControl()
{
   imageToDraw = this.ImageList[0];   
}

protected override OnPaint(PaintEventArgs pe)
{
   pe.Graphics.DrawImage(this.imageToDraw);
  
   // draw a 10-15 other small images 
   ...
}


Can anyone tell me why this is the case? The only difference between the two code snippets is that the first calls DrawImage(imageList.Images[0]) and the second snippet calls DrawImage(someImage). Is retrieving the image out of an image list really that slow?

#include "witty_sig.h"
AnswerRe: Image retrieval from ImageList is slow? Pin
Heath Stewart10-May-04 4:47
protectorHeath Stewart10-May-04 4:47 
GeneralRe: Image retrieval from ImageList is slow? Pin
Judah Gabriel Himango10-May-04 4:53
sponsorJudah Gabriel Himango10-May-04 4:53 
GeneralRe: Image retrieval from ImageList is slow? Pin
Judah Gabriel Himango10-May-04 6:19
sponsorJudah Gabriel Himango10-May-04 6:19 
GeneralRe: Image retrieval from ImageList is slow? Pin
leppie10-May-04 11:55
leppie10-May-04 11:55 
Generaljumping from one form to another Pin
michael.wikstrom10-May-04 3:29
michael.wikstrom10-May-04 3:29 
GeneralRe: jumping from one form to another Pin
Heath Stewart10-May-04 3:35
protectorHeath Stewart10-May-04 3:35 
GeneralSending binary data with webservices Pin
Edgar R. C.10-May-04 3:01
Edgar R. C.10-May-04 3:01 
GeneralRe: Sending binary data with webservices Pin
Heath Stewart10-May-04 3:09
protectorHeath Stewart10-May-04 3:09 
GeneralRe: Sending binary data with webservices Pin
Edgar R. C.10-May-04 3:57
Edgar R. C.10-May-04 3:57 
GeneralRe: Sending binary data with webservices Pin
Heath Stewart10-May-04 4:30
protectorHeath Stewart10-May-04 4:30 
GeneralRe: Sending binary data with webservices Pin
Edgar R. C.11-May-04 9:27
Edgar R. C.11-May-04 9:27 
GeneralRe: Sending binary data with webservices Pin
Heath Stewart10-May-04 4:39
protectorHeath Stewart10-May-04 4:39 
QuestionINT Declarations? Pin
Anonymous10-May-04 2:41
Anonymous10-May-04 2:41 
AnswerRe: INT Declarations? Pin
Heath Stewart10-May-04 2:55
protectorHeath Stewart10-May-04 2:55 
GeneralC# Builder Pin
sreejith ss nair10-May-04 1:01
sreejith ss nair10-May-04 1:01 
GeneralRe: C# Builder Pin
Heath Stewart10-May-04 2:36
protectorHeath Stewart10-May-04 2:36 
QuestionHow to compare the file? Pin
m7779-May-04 22:37
m7779-May-04 22:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.