Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Wrap ImageBuilding::Build2D #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/IntersonArrayCxxImagingContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class IntersonArrayCxx_EXPORT Container
OTHER_ERROR
};

//widthScan and heightScan are the size of the final converted image
ScanConverterError HardInitScanConverter( int depth, int widthScan,
int heightScan, int steering, int depthCfm );

Expand Down Expand Up @@ -118,6 +119,10 @@ class IntersonArrayCxx_EXPORT Container

void SetHWControls(IntersonArrayCxx::Controls::HWControls * controls);

HastingsGreer marked this conversation as resolved.
Show resolved Hide resolved
//Converts an array of b-mode transducer responses into an undistorted
//2-D image of size widthScan, heightScan.
void Build2D(PixelType * bmode_bytedata, PixelType * image_out);

private:

Container( const Container &);
Expand Down
45 changes: 43 additions & 2 deletions src/IntersonArrayCxxImagingContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ limitations under the License.
#include <msclr/auto_gcroot.h>

#using "IntersonArray.dll"
#using "System.Drawing.dll"

#pragma managed

Expand Down Expand Up @@ -245,7 +246,8 @@ class ContainerImpl
Container::ScanConverterError HardInitScanConverter( int depth,
int widthScan, int heightScan, int steering, int depthCfm )
{

this->widthScan = widthScan;
this->heightScan = heightScan;
return static_cast< Container::ScanConverterError >(
WrappedScanConverter->HardInitScanConverter( depth, widthScan,
heightScan, steering, depthCfm, WrappedCapture.get(),
Expand Down Expand Up @@ -332,12 +334,44 @@ class ContainerImpl
{
this->hwControls = controls;
}
void Build2D(Container::PixelType * bmode_bytedata, Container::PixelType * image_out) {
ContainerImpl::ArrayType^ bmode_bytedata_array =
gcnew ArrayType( Container::NBOFLINES, Container::MAX_SAMPLES );

for ( int ii = 0; ii < Container::NBOFLINES; ++ii )
{
for ( int jj = 0; jj < Container::MAX_SAMPLES; ++jj )
{
bmode_bytedata_array[ii, jj] =
bmode_bytedata[Container::MAX_SAMPLES * ii + jj];
}
}

//
System::Drawing::Bitmap^ image =
gcnew System::Drawing::Bitmap(widthScan, heightScan, System::Drawing::Imaging::PixelFormat::Format8bppIndexed);
WrappedImageBuilding->Build2D(image, bmode_bytedata_array, bmode_bytedata_array, WrappedScanConverter.get());
System::Drawing::Imaging::BitmapData^ bmpData = image->LockBits(System::Drawing::Rectangle(0, 0, widthScan, heightScan),
System::Drawing::Imaging::ImageLockMode::ReadOnly,
System::Drawing::Imaging::PixelFormat::Format8bppIndexed);

char* row = reinterpret_cast<char*>(bmpData->Scan0.ToPointer());
for ( int ii = 0; ii < widthScan; ++ii )
{
for ( int jj = 0; jj < heightScan; ++jj )
{
image_out[widthScan * ii + jj] = row[jj];
}
row += bmpData->Stride;
}

}

//
// Begin Wrapped ImageBuilding
//

private:
int widthScan, heightScan;
IntersonArrayCxx::Controls::HWControls * hwControls;
msclr::auto_gcroot< IntersonArray::Imaging::ScanConverter ^ >
WrappedScanConverter;
Expand Down Expand Up @@ -557,6 +591,13 @@ ::SetHWControls(IntersonArrayCxx::Controls::HWControls * controls)
Impl->SetHWControls(controls);
}

void
Container
::Build2D(Container::PixelType * bmode_bytedata, Container::PixelType * image_out)
{
Impl->Build2D(bmode_bytedata, image_out);
}

} // end namespace Imaging

} // end namespace IntersonArrayCxx