Skip to content

Commit 2b8c32c

Browse files
committed
Correct image scaling
1 parent e09b6bb commit 2b8c32c

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

include/IntersonArrayCxxImagingContainer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class IntersonArrayCxx_EXPORT Container
8080
OTHER_ERROR
8181
};
8282

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

@@ -118,6 +119,8 @@ class IntersonArrayCxx_EXPORT Container
118119

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

122+
//Converts an array of b-mode transducer responses into an undistorted
123+
//2-D image of size widthScan, heightScan.
121124
void Build2D(PixelType * bmode_bytedata, PixelType * image_out);
122125

123126
private:

src/IntersonArrayCxxImagingContainer.cxx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ class ContainerImpl
246246
Container::ScanConverterError HardInitScanConverter( int depth,
247247
int widthScan, int heightScan, int steering, int depthCfm )
248248
{
249-
249+
this->widthScan = widthScan;
250+
this->heightScan = heightScan;
250251
return static_cast< Container::ScanConverterError >(
251252
WrappedScanConverter->HardInitScanConverter( depth, widthScan,
252253
heightScan, steering, depthCfm, WrappedCapture.get(),
@@ -337,8 +338,6 @@ class ContainerImpl
337338
ContainerImpl::ArrayType^ bmode_bytedata_array =
338339
gcnew ArrayType( Container::NBOFLINES, Container::MAX_SAMPLES );
339340

340-
int IMAGE_SIZE = 512; // This should be a parameter, however I am working on setting Image Scaling first
341-
342341
for ( int ii = 0; ii < Container::NBOFLINES; ++ii )
343342
{
344343
for ( int jj = 0; jj < Container::MAX_SAMPLES; ++jj )
@@ -349,18 +348,18 @@ class ContainerImpl
349348
}
350349

351350
System::Drawing::Bitmap^ image =
352-
gcnew System::Drawing::Bitmap(IMAGE_SIZE, IMAGE_SIZE, System::Drawing::Imaging::PixelFormat::Format8bppIndexed);
351+
gcnew System::Drawing::Bitmap(widthScan, heightScan, System::Drawing::Imaging::PixelFormat::Format8bppIndexed);
353352
WrappedImageBuilding->Build2D(image, bmode_bytedata_array, bmode_bytedata_array, WrappedScanConverter.get());
354-
System::Drawing::Imaging::BitmapData^ bmpData = image->LockBits(System::Drawing::Rectangle(0, 0, IMAGE_SIZE, IMAGE_SIZE),
353+
System::Drawing::Imaging::BitmapData^ bmpData = image->LockBits(System::Drawing::Rectangle(0, 0, widthScan, heightScan),
355354
System::Drawing::Imaging::ImageLockMode::ReadOnly,
356355
System::Drawing::Imaging::PixelFormat::Format8bppIndexed);
357356

358-
char* row = (char*) reinterpret_cast<char*>(bmpData->Scan0.ToPointer());
359-
for ( int ii = 0; ii < IMAGE_SIZE; ++ii )
357+
char* row = reinterpret_cast<char*>(bmpData->Scan0.ToPointer());
358+
for ( int ii = 0; ii < widthScan; ++ii )
360359
{
361-
for ( int jj = 0; jj < IMAGE_SIZE; ++jj )
360+
for ( int jj = 0; jj < heightScan; ++jj )
362361
{
363-
image_out[IMAGE_SIZE * ii + jj] = row[jj];
362+
image_out[widthScan * jj + ii] = row[jj];
364363
}
365364
row += bmpData->Stride;
366365
}
@@ -372,6 +371,7 @@ class ContainerImpl
372371
//
373372

374373
private:
374+
int widthScan, heightScan;
375375
IntersonArrayCxx::Controls::HWControls * hwControls;
376376
msclr::auto_gcroot< IntersonArray::Imaging::ScanConverter ^ >
377377
WrappedScanConverter;

0 commit comments

Comments
 (0)