Skip to content

Commit

Permalink
Merge branch 'micro-manager:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars-Kool authored Jul 1, 2024
2 parents 3fca3cf + 1ee1bf7 commit 557a1f3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 18 deletions.
2 changes: 1 addition & 1 deletion DeviceAdapters/ASIStage/ASICRISP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ int CRISP::OnNA(MM::PropertyBase* pProp, MM::ActionType eAct)
}
else if (eAct == MM::AfterSet)
{
long na;
double na;
pProp->Get(na);
std::ostringstream command;
command << std::fixed << "LR Y=" << na;
Expand Down
77 changes: 61 additions & 16 deletions DeviceAdapters/PCO_Generic/MicroManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const char* g_CameraDeviceName = "pco_camera";
const char* g_PixelType_8bit = "8bit";
const char* g_PixelType_16bit = "16bit";
const char* g_PixelType_RGB32bit = "RGB 32bit";
const char* g_PixelType_RGB48bit = "RGB 48bit";

const char* g_TimeStamp_No = "No stamp";
const char* g_TimeStamp_B = "Binary";
Expand Down Expand Up @@ -1008,8 +1009,10 @@ int CPCOCam::OnPixelType(MM::PropertyBase* pProp, MM::ActionType eAct)
pixelDepth_ = 2;
else if(pixType.compare(g_PixelType_8bit) == 0)
pixelDepth_ = 1;
else if(pixType.compare(g_PixelType_RGB32bit) == 0)
else if (pixType.compare(g_PixelType_RGB32bit) == 0)
pixelDepth_ = 4;
else if (pixType.compare(g_PixelType_RGB48bit) == 0)
pixelDepth_ = 6;
else
{
return DEVICE_INTERNAL_INCONSISTENCY;
Expand All @@ -1022,8 +1025,10 @@ int CPCOCam::OnPixelType(MM::PropertyBase* pProp, MM::ActionType eAct)
pProp->Set(g_PixelType_8bit);
else if(pixelDepth_ == 2)
pProp->Set(g_PixelType_16bit);
else if(pixelDepth_ == 4)
else if (pixelDepth_ == 4)
pProp->Set(g_PixelType_RGB32bit);
else if (pixelDepth_ == 6)
pProp->Set(g_PixelType_RGB48bit);
else
{
return DEVICE_INTERNAL_INCONSISTENCY;
Expand Down Expand Up @@ -1380,8 +1385,12 @@ int CPCOCam::Initialize()
pixTypes.push_back(g_PixelType_16bit);
pixTypes.push_back(g_PixelType_8bit);

if(m_pCamera->GetCCDCol(0))
if (m_pCamera->GetCCDCol(0))
{
pixTypes.push_back(g_PixelType_RGB32bit);
//pixTypes.push_back(g_PixelType_RGB48bit); // Not possible up to now 07/22
// Also GetImage does not convert to 48bit rgb, just 32bit rgb
}

nRet = SetAllowedValues(MM::g_Keyword_PixelType, pixTypes);
if(nRet != DEVICE_OK)
Expand Down Expand Up @@ -1663,10 +1672,14 @@ unsigned CPCOCam::GetBitDepth() const
{
return m_pCamera->GetBitsPerPixel();
}
else if(img_.Depth() == 4)
else if (img_.Depth() == 4)
{
return 8;
}
else if (img_.Depth() == 6)
{
return 16;
}
else
{
return 0; // should not happen
Expand Down Expand Up @@ -1746,9 +1759,9 @@ const unsigned char* CPCOCam::GetBuffer(int ibufnum)
ppic8 += iadd;
}
}
else if(img_.Depth() == 4)
else if (img_.Depth() == 4)
{
if(m_bDoAutoBalance)
if (m_bDoAutoBalance)
{
m_pCamera->SetLutMinMax(TRUE, TRUE);
m_pCamera->AutoBalance(0, 0, 0, 0, 0);
Expand All @@ -1757,28 +1770,60 @@ const unsigned char* CPCOCam::GetBuffer(int ibufnum)
m_pCamera->Convert(ibufnum);
iw = img_.Width();
ih = img_.Height();
unsigned char *pchar;
unsigned char *ppic8, *ph;
unsigned char* pchar;
unsigned char* ppic8, * ph;
int iadd;

ppic8 = m_pCamera->GetPic8c();

iadd = (iw * 3) % 4;
if(iadd != 0)
if (iadd != 0)
iadd = 4 - iadd;
pchar = const_cast<unsigned char*>(img_.GetPixelsRW());
for(int y = 0; y < ih; y++)
for (int y = 0; y < ih; y++)
{
ph = &ppic8[y*(iw * 3 + iadd)];
for(int x = 0; x < iw; x++)
ph = &ppic8[y * (iw * 3 + iadd)];
for (int x = 0; x < iw; x++)
{
*pchar++ = (unsigned char) *ph++;
*pchar++ = (unsigned char) *ph++;
*pchar++ = (unsigned char) *ph++;
*pchar++ = (unsigned char)*ph++;
*pchar++ = (unsigned char)*ph++;
*pchar++ = (unsigned char)*ph++;
*pchar++ = 0;
}
}
}
else if (img_.Depth() == 6)
{
if (m_bDoAutoBalance)
{
m_pCamera->SetLutMinMax(TRUE, TRUE);
m_pCamera->AutoBalance(0, 0, 0, 0, 0);
m_bDoAutoBalance = FALSE;
}
m_pCamera->Convert(ibufnum);
iw = img_.Width();
ih = img_.Height();
unsigned short* pchar;
unsigned char* ppic8, * ph;
int iadd;

ppic8 = m_pCamera->GetPic8c();

iadd = (iw * 3) % 4;
if (iadd != 0)
iadd = 4 - iadd;
pchar = (unsigned short*)(img_.GetPixelsRW());
for (int y = 0; y < ih; y++)
{
ph = &ppic8[y * (iw * 3 + iadd)];
for (int x = 0; x < iw; x++)
{
*pchar++ = (unsigned char)*ph++;
*pchar++ = (unsigned char)*ph++;
*pchar++ = (unsigned char)*ph++;
}
}
}

if(nErr != 0)
return 0;
Expand Down Expand Up @@ -2165,7 +2210,7 @@ int CPCOCam::ResizeImageBuffer()
m_iHeight = nHeight;
}

if(!(pixelDepth_ == 1 || pixelDepth_ == 2 || pixelDepth_ == 4))
if(!(pixelDepth_ == 1 || pixelDepth_ == 2 || pixelDepth_ == 4 || pixelDepth_ == 6))
return -1;
img_.Resize(nWidth, nHeight, pixelDepth_);
SetSizes(nWidth, nHeight, pixelDepth_);
Expand Down
2 changes: 1 addition & 1 deletion secret-device-adapters-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fa7a9069a0a99f32f283de8767b452339afb7775
574f3c801e6df2b0fa761298ddc32ac64dce58ce

0 comments on commit 557a1f3

Please sign in to comment.