Examining and Altering Bitmaps
You can make many changes to the bitmap in memory, but keep in mind that the changes do not appear on the screen until the image repaints.
Getting Bitmap Information
Get information about the bitmap from the following properties and method:
Getting and Setting Pixel Values
Use the following method to get and set the values of individual pixels:
Changing the Data Format
Use the following methods to change the bits per pixel and palette of a bitmap or bitmap list:
Use the following methods to change a bitmap to 8-bit grayscale or to a 1-bit halftone:
Bitmap data can be signed or unsigned. If the bitmap data is signed, image processing and paint functions may not work correctly. A bitmap will not be loaded signed unless the LoadSigned property is set to TRUE before loading the image. To determine whether the bitmap loaded into the control is signed or not, check the IsSigned property. If this property is TRUE, the bitmap data is signed and should be converted.
Image data can be changed from signed to unsigned and vice versa. Signed image data may contain some negative values. Converting data from signed to unsigned, and vice versa, will be done by shifting the image data or intensity values by a specific value. The ability to shift image data back and forth between signed and unsigned is often useful in medical or analytical applications.
To change image data from signed to unsigned, which is often done before applying image processing or analysis functions, there are the following options:
ConvertUnsignedToSigned shifts the image data based on internal aspects of the image.
ShiftMinimumToZero provides the user with the value by which the image data was shifted by updating the ShiftAmount property. This information can be used later, after image processing, to return the image to signed data.
Once signed images have been converted to unsigned images image processing or analysis can be performed on the unsigned images. (Most image processing methods work only on unsigned data.) When the image processing or analysis is complete, convert the unsigned data back to signed data.
To change image data from unsigned to signed, which is often done after applying image processing or analysis methods, there are the following options:
ConvertSignedToUnsigned shifts the image data based on internal aspects of the image.
ShiftZeroToNegative gives the user the ability to specify the amount by which to shift the image data, and dictates the minimum and maximum values that are output by the function.
Windows always uses the RGB color-space model, and when loading or saving a file, LEADTOOLS converts image data to or from RGB, as necessary. Nevertheless, LEADTOOLS lets you create and merge color separations using a number of color-space models, including RGB, CMYK, CMY, HSV, and HLS. Use the ColorSeparate method to create separations, use the ColorMerge method to merge separations, and use the ColorPlanes property to access the separated planes.
Updating the Line Profiles
Doing Geometric Transformations
Geometric transformations include resizing, trimming, rotating, shearing, flipping, or reversing a bitmap. The following geometric transformation functions are designed mainly for document imaging:
Deskew method (Document/Medical only)
FastRotate method (Document/Medical only)
Use the following method to resize the bitmap. Keep in mind that this changes the amount of memory required for the bitmap, and it is not necessary to do this for zooming in or out.
Use the following methods to alter a bitmap in various ways:
LEADTOOLS also provides the TransformFile method for performing lossless flips, rotations and reversals. However, only certain file formats are supported at this time. This function provides better results than loading an image, transforming it using the Rotate method, Flip method or Reverse method and then resaving it. For each marker that the TransformFile method encounters within a file, the TransformMarker event is triggered. Within this event the user sets the WriteMarkerAction property to indicate what action to take with the marker. If the marker is to be written to the output file, the user calls the WriteMarker method.
Lightening, Darkening, Filtering, and So Forth
A number of image processing functions let you change the values of pixels across a bitmap (or a region in the bitmap) using various algorithms and filters. You might do this to improve the appearance of the image, to analyze details in the image, or to apply artistic effects. The following topics provide details:
Changing Brightness and Contrast
Detecting and Enhancing Edges and Lines
Adding Another Image to a Bitmap
The Combine method lets you add all or part of another bitmap to the target bitmap. You can pass flags to control whether the new pixels simply replace the old ones or are combined with the old ones in a specified way. You can also define a region in the target bitmap, and if you do, the function affects only the specified region. For information about regions, refer to Creating and Using a Bitmap Region. For more information on combining images, refer to Combining Images.
The Underlay method also combines images, but it has a much more specific purpose. It combines two bitmaps so that one appears to be an underlying texture for the other.
Treating the bitmap as a device context opens up many possibilities You can set the DrawPersistence property to TRUE to draw text or objects on the bitmap. For details, refer to Drawing Simple Objects and Drawing Three-Dimensional Shapes and Text.
Also, the GetBitmapDC method lets you access the bitmap as a device context. You can then use Windows GDI functions to draw lines, text, or images on the bitmap. For more information, refer to Using the Windows API.
To replace an image with an image created from images in a specified directory, use the Picturize method.
Subtracting One Bitmap From Another
The DigitalSubtract method does not combine images, but subtracts the live (destination) bitmap from the mask (source) bitmap to show the differences between the two bitmaps.
The ColorHalfTone method creates an enlarged halftone screen for each image channel. To creates a halftone screen effect for an image while keeping its continuous range of tones the HalfTonePattern method.
Extracting Bitmaps From A Series
The Slice method is designed to extract the individual slices from radiographic scanned film. For each slice segment found, an OnSliceBitmap Event is fired. Set the ContinueSlicing property to VARIANT_FALSE to stop the slicing operation. If you set the Slice method to perform a deskewing operation, call the SliceDeskewAngle property afterwards to determine how much the Slice method rotated the image.