My app jams
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: My app jams

Hybrid View

  1. #1
    Join Date
    Jan 2010

    My app jams

    hi all,

    I have just wrote my first app in WPF (actually it is my first windows app). It is an image resizer which converts pictures correctly but it jams when I load large number of images (The window freezes and I cant move it).

    I have a list of strings where each item represents location of the image. Then I run the following loop:

    foreach (string file in fileCollection)

    FileInfo fInfo = new FileInfo(file);
    Image tempImg2 = Image.FromFile(fInfo.FullName);
    string imgName = fInfo.Name.Substring(0, fInfo.Name.Length - 4);
    if (isOriginalSize == true)
    finalImage = tempImg2;
    finalImage = tempImg2.GetThumbnailImage(imageWidth, imageHeight, null, IntPtr.Zero);
    Bitmap bmp1 = new Bitmap(finalImage);
    ImageCodecInfo jpgEncoder = GetEncoder(ImageFormat.Jpeg);
    System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;
    EncoderParameters myEncoderParameters = new EncoderParameters(1);
    EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, imgQualityValue);
    myEncoderParameters.Param[0] = myEncoderParameter;

    bmp1.Save(@ofd_out.SelectedPath + "\\" + imgName + outputFormat, jpgEncoder, myEncoderParameters);


    What can I do to improve performance of my program? Should I use threading or something else?

    Thank you,

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004

    Re: My app jams

    Yes, I'd create a class that does the loading/conversion in a different thread and then use events to notify the main UI thread of the conversion progress.

  3. #3
    Join Date
    Jan 2010

    Re: My app jams

    Thanks very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center