Code sample Home

Create raster image (from a file)
void DemoImage (HANDLE hLcWnd)
{
  HANDLE hDrw, hBlock, hImage, hImage2, hImageRef;
  WCHAR* szImageFile1 = L"d:/___TMP/Image01.jpg";
  WCHAR* szImageFile2 = L"d:/___TMP/Image03.png";
  double X, Y, W, H, W2, Xc, Yc;
  int    Wpix, Hpix;

  // get drawing and block, linked with CAD window
  hDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );

  // add raster image from a file
  hImage = lcDrwAddImage( hDrw, L"", szImageFile1 );
  // get image dimensions (pixels)
  Wpix = lcPropGetInt( hImage, LC_PROP_IMAGE_WPIX );
  Hpix = lcPropGetInt( hImage, LC_PROP_IMAGE_HPIX );
  // add one more raster image
  hImage2 = lcDrwAddImage( hDrw, L"", szImageFile2 );

  // insert the image into a drawing
  X = 0.0;
  Y = 0.0;
  W = 100.0;  // width of image ref. (height will be set according the ratio of image dimensions)
  hImageRef = lcBlockAddImageRef( hBlock, hImage, X,Y, W,0, true );
  // get height of the image reference
  H = lcPropGetFloat( hImageRef, LC_PROP_IMGREF_H );

  // add 2nd image reference above the 1st
  Y+=H;
  hImageRef = lcBlockAddImageRef( hBlock, hImage, X,Y, W,0, false );
  // flip vertically
  lcPropPutBool( hImageRef, LC_PROP_IMGREF_FLIPVER, true );
  // and make it greyscale
  lcPropPutBool( hImageRef, LC_PROP_IMGREF_GREY, true );

  // add 3rd image reference at right of the 2nd
  X+=W;
  hImageRef = lcBlockAddImageRef( hBlock, hImage, X,Y, W,0, true );
  // reduce resolution 8 times
  lcImgRefResize( hImageRef, Wpix/8, Hpix/8, LC_IMGRES_BICUBIC );

  // add 4rd image reference
  Y-=H;
  hImageRef = lcBlockAddImageRef( hBlock, hImage, X,Y, W,0, false );
  // get center point
  Xc = lcPropGetFloat( hImageRef, LC_PROP_IMGREF_XC );
  Yc = lcPropGetFloat( hImageRef, LC_PROP_IMGREF_YC );
  // scale and rotate the image ref.
  lcEntScale( hImageRef, Xc, Yc, 0.8 );
  lcEntRotate( hImageRef, Xc, Yc, 30.0 * LC_DEG_TO_RAD );

  // add image ref. of hImage2
  Y += H;
  W2 = W / 4.0;
  hImageRef = lcBlockAddImageRef( hBlock, hImage2, X-W2/2, Y-W2/2, W2,0, false );
  // set transparent color
  lcPropPutInt( hImageRef, LC_PROP_IMGREF_TRANSP, 1 );
  lcPropPutInt( hImageRef, LC_PROP_IMGREF_TRCOLOR, RGB(255,255,255) );

  // display
  lcBlockUpdate( hBlock, true, 0 );
  lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}

This will create the following drawing: