ClearImage COM API
CreateBpp Method
CiImage Object : CreateBpp Method
Width of the new image in pixels
Height of the new image in pixels
Color scheme of the new image in pixels. Valid values are 1, 8, 24
Description
Create an image (bpp = 1, 8, 24)
Syntax
Visual Basic
Public Sub CreateBpp( _
   ByVal Width As Long, _
   ByVal Height As Long, _
   ByVal BitsPerPixel As Long _
) 
Parameters
Width
Width of the new image in pixels
Height
Height of the new image in pixels
BitsPerPixel
Color scheme of the new image in pixels. Valid values are 1, 8, 24
Remarks

If BitsPerPixel = 1 this method creates a bi-tonal image with all pixels are set to white and resolution is 300 dpi.

If BitsPerPixel = 8 or  BitsPerPixel = 24 this method creates a grayscale (GS) or color (RGB) image respectively. All pixels are set to black and resolution is 1 dpi.  Set HorzDpi and VertDpi properties to the required value. 

This method generates an error if object.Image.IsZone is true.

 

Example
Sub ImageMethods()
  Dim Ci As New CiServer
  Dim image As CiImage: Set image = Ci.CreateImage
    '  Initialize 3000 pixels * 2000 pixels RGB image. All pixels of new RGB image are black.  Default resolution is 1 dpi
  image.CreateBpp 3000, 2000, 24
    '  Set DPI to 200
  image.HorzDpi = 200: image.VertDpi = 200
    '  Crop area of the image
  image.Crop 100, 200, 800, 1000
    '  Initialize 8.5" by 11" bi-tonal image. All pixels of new Bi-tonal image are white.  Default resolution is 300 dpi
    '  Image initialization closes and frees memory of the previously crated RGB image
  image.Create 8.5 * 300, 11 * 300
    '  Convert to grayscale
  image.ToGrayscale
    '  Create zone in the center of the image
  Dim zoneCenter As CiImage
  Set zoneCenter = image.CreateZone(image.Width / 3, image.Height / 3, _
                image.Width * 2 / 3, image.Height * 2 / 3)
    '  Invert center area of the image
  zoneCenter.Invert
    '  Re-define zone to upper left quadrant of the image
  Dim rect As CiRect: Set rect = Ci.CreateRect
  rect.Left = 0: rect.Right = image.Width / 2
  rect.Top = 0: rect.bottom = image.Height / 2
  Dim zoneCorner As CiImage
  Set zoneCorner = image.CreateZoneRect(rect)
    '  Clear corner area on the image
  zoneCorner.Clear
    '  Duplicate center area to a new image
  Dim imageCenter As CiImage
  Set imageCenter = zoneCenter.Duplicate
    '  Copy from the original image
  Dim imageCopy As CiImage: Set imageCopy = Ci.CreateImage
  imageCopy.Copy image
    '  Convert image to bi-tonal
  imageCopy.ToBitonal
    '  Clean-up. Free image memory
  image.Close
  imageCenter.Close
  imageCopy.Close
End Sub
See Also

CiImage Object  | CiImage Members