Search code examples
leadtools-sdk

What is the initial value of ViewPerspective after loading image using LeadTools?


When loading images using LeadTools API, what would be the initial value of ViewPerspective?

My experiments with below code snippet revealed it is always BOTTOM_LEFT (4).

BITMAPHANDLE LeadBitmap2;
L_INT nRet = L_ConvertFromDIB(&LeadBitmap2, sizeof(BITMAPHANDLE), (BITMAPINFO*)pucTestBuffer, pDIBits);
// Here LeadBitmap2.ViewPerspective was BOTTOM_LEFT

BITMAPHANDLE LeadBitmapChanged;
L_ChangeBitmapViewPerspective(&LeadBitmapChanged, &LeadBitmap2, sizeof(BITMAPHANDLE), TOP_LEFT);
// Here LeadBitmapChanged.ViewPerspective was TOP_LEFT as expected.

Here I converted LeadTool Bitmap with changed perspective to DIB and created a new LeadTool Bitmap using L_ConvertFromDIB()

L_HDIB hDIB = L_ConvertToDIB(&LeadBitmapChanged, DIB_BITMAPINFOHEADER);
unsigned char* pBmi = (unsigned char*)::GlobalLock(hDIB);

BITMAPHANDLE LeadBitmap4;
nRet = L_ConvertFromDIB(&LeadBitmap4, sizeof(BITMAPHANDLE), (BITMAPINFO*)pBmi, 
    pBmi + sizeof(BITMAPHANDLE) + ((BITMAPINFO*)pBmi)->bmiHeader.biClrUsed * sizeof(RGBQUAD));

Here LeadBitmap4.ViewPerspective was again BOTTOM_LEFT. Could we assume it is always BOTTOM_LEFT when you load image using LeadTools? LeadTools documentation doesn't say anything about the default/initial value of ViewPerspective.


Solution

  • The view perspective is not fixed for all images but depends on the image format. For example, when loading PNG file form disk, the view perspective will be TOP_LEFT. For loading Windows BMP files, or when converting a Windows Device Independent Bitmap (DIB), the view perspective is usually BOTTOM_LEFT. For the TIFF file format, it can be almost any view perspective depending on the orientation tag in TIFF itself.

    If you want the image to be of a specific orientation, you can always change the view perspective by calling "L_ChangeBitmapViewPerspective" after loading or converting the image. For more information read the topic for the L_ChangeBitmapViewPerspective() function in our help files.