Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

ResampleCommand - image size ignored?

Last post 12 Sep 2007, 9:51 AM by reignman. 3 replies.
Sort Posts: Previous Next
  •  06 Aug 2007, 7:26 AM 12468

    ResampleCommand - image size ignored?

    I've got a problem with the ResampleCommand. I want to scale my image (JPG) to another size (given by destWidth and destHeight) and save it, but the image keeps its original size. I've tried:

      workspace.Image = image;
      workspace.ApplyCommand(new ResampleCommand(new Size(destWidth, destHeight),
      ResampleMethod.LanczosFilter)); //resampleMethod
      workspace.Dispose();

     ...

      image.Save(infoDest.FullName, enc, null);

     

    The image is saved with the original size. Can anybody tell me how to get it to take destWidth & destHeight into account?

     

    Many thanks,
    r.

    Filed under: ,
  •  06 Aug 2007, 11:38 AM 12470 in reply to 12468

    Re: ResampleCommand - image size ignored?

    There's another problem when trying to save a PNG with the same method code, here's the trace:

    --> Error in method SimpleConvertToImage
    An exception occurred converting from \"C:\\some-logo.png\" to JPEG image \"C:\\Dokumente und Einstellungen\\some\\Desktop\\CFP\\some-logo.jpg\":
    Auf das verworfene Objekt \"AtalaImage\" kann nicht zugegriffen werden.
    Objektname: \"AtalaImage\".\n--> Error in method SimpleConvertToImage
    An exception occurred converting from \"C:\\some-logo.png\" to JPEG image \"C:\\Dokumente und Einstellungen\\some\\Desktop\\CFP\\some-logo.jpg\":
    Auf das verworfene Objekt \"AtalaImage\" kann nicht zugegriffen werden.
    Objektname: \"AtalaImage\".

     

    The last line says "The discarded object 'AtalaImage' can not be accessed".

    What does that mean?

     

    Thanks in advance for any hints,

    r. 

  •  06 Aug 2007, 3:29 PM 12472 in reply to 12468

    Re: ResampleCommand - image size ignored?

    You need to set your "image" variable to the workspace.Image property.  ResampleCommand creates a new image, so your original image is not modified.  You also need to set the Workspace.AutoDispose property to false so it will not dispose the resized image when you call workspace.Dispose().

     


    Glenn Chittenden Jr.
    Atalasoft Development Team
  •  12 Sep 2007, 9:51 AM 12553 in reply to 12472

    Re: ResampleCommand - image size ignored?

    Thank you!
View as RSS news feed in XML