anhngml / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

Resolution of Bitmap returned by BaseTransformationFilter.Apply is default #228

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Image foo is 720x720dpi
2. var cropArea = new Rectangle(0, 0, 100, 100);
2. var cropper = new Crop(cropArea);
3. var bar = cropper.Apply(foo);
4. Note: bar.HorizontalResolution == bar.HorizontalResolution == 96;

What is the expected output? What do you see instead?
I would expect that the new resulting image have the same resolution as the 
source. Instead it is the default value of 96.

What version of the product are you using?
2.1.5

Please provide any additional information below.
Suggested fix:

===================================================================
--- AForge.NET Framework-2.1.5/Sources/Imaging/Filters/Base 
classes/BaseTransformationFilter.cs (revision 4356)
+++ AForge.NET Framework-2.1.5/Sources/Imaging/Filters/Base 
classes/BaseTransformationFilter.cs (revision 4357)
@@ -71,6 +71,8 @@
             {
                 // apply the filter
                 dstImage = Apply( srcData );
+                // set the destination's resolution to match the source
+                dstImage.SetResolution(image.HorizontalResolution, 
image.VerticalResolution);
             }
             finally
             {

Original issue reported on code.google.com by yvan.rod...@gmail.com on 21 Jun 2011 at 6:23

Attachments:

GoogleCodeExporter commented 9 years ago
The suggested fix may work for transformation filters. But it is not generic 
for all other filters, which create new image as result of image processing.

Original comment by andrew.k...@gmail.com on 21 Jun 2011 at 7:21

GoogleCodeExporter commented 9 years ago
Setting horizontal/vertical resolution of result image to the same values as 
source image has. The fix is applied to filters and image processing routines 
which accept Bitmap as parameter and return Bitmap as result. Obviously it can 
not copy DPI settings when image processing routine is applied to BitmapData or 
UnmanagedImage.

Committed in revision 1605. Will be released in version 2.2.2.

Original comment by andrew.k...@gmail.com on 13 Sep 2011 at 7:48

GoogleCodeExporter commented 9 years ago

Original comment by andrew.k...@gmail.com on 18 Sep 2011 at 7:56