Grab to MMF

Post and discuss your API application solutions here.
user-4919
Posts: 10
Joined: Thu Jan 01, 1970 1:00 am

Grab to MMF

Post by user-4919 »

Hello,

I try to grab an image from SEM to a MMF file. It works but when I tyr to grab a bigger image (resolution 2048*1536 or bigger), the grab failed.

How could I find a solution of this exception ?

Regards,
user-42
Posts: 27
Joined: Thu Jan 01, 1970 1:00 am

Post by user-42 »

Hello Olivier,

Does your application maybe still hold a handle to CZ.MMF while you are changing to a higher store resolution? This would cause a grab failure.

Best regards,
Heiko
user-4919
Posts: 10
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4919 »

Hello,


No, here my code :

long lResult = CZEMApi.Grab(xdeb, ydeb, WidthGrab, HeightGrab, reduction, strFileName);
if (lResult != 0) // test de grab
{
LogInfo("Erreur Grab Image to MMF Ligne : "+Ligne.ToString()+" Colonne : "+Colonne.ToString());

}

IntPtr fileHandle = OpenFileMapping(SECTION_MAP_READ, false, strFileName);
if (fileHandle == IntPtr.Zero)
{
LogInfo("Erreur OpenFileMapping Grab Image to MMF");
}
else
{
// Obtain a read/write map for the entire file
IntPtr fileMap = MapViewOfFile(fileHandle, SECTION_MAP_READ, 0, 0, 0);

if (fileMap == IntPtr.Zero)
{
LogInfo("Erreur MapViewOfFile Grab Image to MMF");
}
else
{


Marshal.Copy(fileMap, FileData, Fileoffset, iSizeGrab * 2);// Copy the bytes to ByteArray




//Clean up
UnmapViewOfFile(fileMap);
}
//Clean up
CloseHandle(fileHandle);
user-4919
Posts: 10
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4919 »

Do you see a problem in my code ?
user-42
Posts: 27
Joined: Thu Jan 01, 1970 1:00 am

Post by user-42 »

Hello Olivier,

sorry, I thought that I had already replied to your question. I don't think it is a problem in your code.

The Grab() documentation in the API Manual says 'The image size you are trying to grab should be in the X-range of 0-1024 and Y-range of 0-768, independent of the image store resolution.'

I don't know why it says 'should', but I would assume that it means that for Grab to MMF, sizes larger than 1024 x 768 just won't work in general.

Best regards,
Heiko
user-4919
Posts: 10
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4919 »

Hello,

Thanks for your reply.

Ok, so I've tried to grab a larger image by "cutting" into smaller image (ex for a 2048*1536 i've tried to grab 4 images at 1024*768). But the grab are not good (images distorded, sometimes black).

Do you know the reason ? It's a problem for us...

Another question, in my API documentation (SmartSEM Remote API Manual.pdf), I don't find the image range size, what kind of documentation do you use ?

Regards,
user-42
Posts: 27
Joined: Thu Jan 01, 1970 1:00 am

Post by user-42 »

Hi Olivier,

I have forwarded your Grab to MMF question to our software development department. I hope they can solve the problem.
I will also send you a copy of the newest version of the API Manual to your email address.

Regards,
Heiko
user-42
Posts: 27
Joined: Thu Jan 01, 1970 1:00 am

Post by user-42 »

Hello Olivier,

Below I am forwarding the information from our software developers:


The resolution you mention is one of the “standard” four resolutions so all systems support it.

The API manual (Remote API 5.3) continues to say: "The size of the grabbed image is determined by the value of the parameter
DP_IMAGE_STORE. See the appendix for possible values of DP_IMAGE_STORE and their meaning."

Please check the MMF functionality on a real machine with the C++ API program when changing “DP_IMAGE_STORE”to larger files. This will give larger files in the MMF!

See the API test program source code in function:

void CSmartSEM_API_TestDlg::OnBnClickedBtnGrabMmf()

With larger values of the image store, we can safely expand the width and height of the MMF:

// get param value
CString str("DP_IMAGE_STORE");
long lResult = m_cApi.Get(str, &var);
switch ((int)var.fltVal)
{
case 0://S_RES_STD:
break;
case 1://S_RES_HALF:
width/=2;
height/=2;
break;
case 2://S_RES_2:
width*=2;
height*=2;
break;
case 3://S_RES_3:
width*=3;
height*=3;
break;
}


I hope this helps.

Best regards,
Heiko
user-4919
Posts: 10
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4919 »

Hello Heiko,

I've already done this method, but when I try to grab directly in 2048*1536, the grab function returns an error code (1016). That's why I'm here ! :D

And that's why I try to grab by cutting the image in smaller part, but the grab is not good.

Regards,
user-42
Posts: 27
Joined: Thu Jan 01, 1970 1:00 am

Post by user-42 »

Dear Olivier,

You told me that your API version is 4.0. However, for SmartSEM 5.05 the matching API version is 3.6. Although using a higher version usually works fine, you may try to go back to 3.6 and see if it works with that version.

There was a Grab to MMF bug that prevented store resolutions larger than 1024x768 to be grabbed, but that bug was supposed to be fixed in SmartSEM 5.05. Our software guys tell me they have tried to grab store resolutions larger than 1024x768 with SmartSEM 5.05 and API 3.6 using the API Test program, and it worked fine.

Apart from the Grab to MMF Problem, SmartSEM 5.05 is quite old, so you may consider upgrading to 5.07 some time.

Best regards,
Heiko
Post Reply