ClearImage COM Server
LoadFromMemory Method
See Also  Example  Send Feedback
pData
CiImage Object : LoadFromMemory Method

Description

Load image bits from image memory

Syntax

Visual Basic
Public Sub LoadFromMemory( _
   ByVal pData As Variant _
) 

Parameters

pData

Remarks

!MISSING PHRASE '_ZONEFAIL_IMG'!

The structure of image memory is:

  • Lines are stored starting from the top line of the image.
  • Each row should be at least object.LineBytes long
  • Minimum size of image memory should be:
    ImageBytes  =  object.Height  * object.LineBytes
  • If bytes extend beyond image boundary, extra bytes are ignored.

The structure of image memory for a buffer of a Bitonal image is:

  • Each byte represents 8 pixels with the most significant bit corresponding to the leftmost pixel.
  • Zero value of the bit is treated as black pixel.

 The structure of image memory for a buffer of a Grayscale image is:

  • Each byte represents an image pixel
  • Byte value represents pixel intensity with 0x00 for black pixel and 0xFF for white pixel

 The structure of image memory for a buffer of a Color image is:

  • Each image pixel is represented by 3 bytes
  • 3-Byte value represents RGB color of a pixel with 0x000000 for black pixel and 0xFFFFFF for white pixel

Example

VBExample (Visual Basic)Copy Code
Public Sub T_LoadFromMemory(ByRef Image As CiImage, _
        Width, Height, Mem() As Byte)
  Image.Create Width, Height
  Image.LoadFromMemory Mem
End Sub
C++ Example (C++)Copy Code
bool MemoryToImage (ICiImagePtr &Image, long w, long h, long bpp, char *pSrc, long nSize)
    {
    bool bRet = false;
    _variant_t v;
    SAFEARRAY* psa;
    char *pByte = NULL;
    SAFEARRAYBOUND bounds  = {nSize, 0};
    Image->CreateBpp (w, h, bpp);
    psa = SafeArrayCreate (VT_UI1, 1, &bounds);
    if (!psa)
        goto EXIT;
        // Transfer data into safearray
    SafeArrayAccessData (psa, reinterpret_cast <void **> (&pByte));
    memcpy (pByte, pSrc, nSize);
    SafeArrayUnaccessData (psa);
        // Put safearray into variant
    v.vt = VT_ARRAY | VT_UI1;
    v.parray = psa;
        // Load variant data into image
    Image->LoadFromMemory(v);
    bRet = true;
EXIT:
    return bRet;
    }

See Also

© 1992-2011. Inlite Research, Inc. All Rights Reserved.