johniewalker229 / aforge

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

ReplaceChannel with UnmanagedImage throws NullReferenceException #344

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create RGB UnmanagedImage ->
Dim tmpImg As AForge.Imaging.UnmanagedImage = 
AForge.Imaging.UnmanagedImage.FromManagedImage(foundImg)

2. Create channel image ->
Dim exChan As New AForge.Imaging.Filters.ExtractChannel(AForge.Imaging.RGB.R)
Dim redChan As AForge.Imaging.UnmanagedImage = exChan.Apply(tmpImg)

3. Insert the modified channel back to the original image ->
Dim replaceChan As New 
AForge.Imaging.Filters.ReplaceChannel(AForge.Imaging.RGB.R, redChan)
replaceChan.ApplyInPlace(tmpImg)    **** Throws the NULL Error

What is the expected output? What do you see instead?
I expect the ReplaceChannel to replace the designated channel. Instead, a Null 
Reference is thrown. There is a work around to fix this (see below).

What version of the product are you using?
2.2.4

Please provide any additional information below.
Convert the target image and replacement channel to a System.Drawing.Bitmap 
object before running the ReplaceChannel function. This runs with no problems.

Original issue reported on code.google.com by dst...@email.arizona.edu on 28 Apr 2013 at 4:44

GoogleCodeExporter commented 8 years ago
In the file ReplaceChannel.cs replace the line 277
  int offsetCh = chData.Stride - rect.Width;
with this line
  int offsetCh = chStride - rect.Width;
and compile the code.

Original comment by philipp....@gmail.com on 15 Jul 2015 at 9:44