Main Menu

All times are in GMT -8 (DST) :: The time is now 8:20 pm.

Login or Register
Create an account and register your LMI products to gain access to useful resources.

Register Account

Login

Sub Menu

Knowledge Base
Article Data
Article Ref
8694-QRJX-4026
Date Created
Mon, 18th Jul 2011
Date Modified
Mon, 6th Mar 2017

   How to create images in a HSDataBase without using the AcquisitionDevice in C++

Question 

How can I create images in a HSDataBase without using the AcquisitionDevice in  C++?

Answer 

HSDatabase lDB = mApplicationControl.GetDatabase();

 

HSView lView = lDB.AddView ("New View");

const long ltype = HSImage::hsImageType::hsImage32bppRgb;

HSImage lImage = lView.AddImage("New Image",COleVariant(ltype));

 

lImage.SetWidth( 10 );

lImage.SetHeight( 10 );

 

// RawImagePointer may be changed after the allocation from SetWidth/SetHeight

// (hsImage32bppRgb represent a DWORD, hsImage8bppGreyScale is a BYTE)

DWORD* lPtr = (DWORD*)lImage.GetRawImagePointer();

 

for( int i=0; i<10; i++ )

{

    for( int j=0; j<10; j++ )

    {

        // The two lines in here are both valid, the raw pointer, however, is faster

 

        //lImage.SetPixel(i,j,0xffffff);

        lPtr[j+i*(int)lImage.GetWidth()] = 0xffffff;

    }

}