The StartDibAccess method is used to allow access to pixels in the Device Independent Bitmap (DIB). This method is to be used in conjunction with the EndDibAccess method.

[C++Builder]   [ bool = ]imagekitcontrolname->Effect->StartDibAccess(NativeUInt hDib, short &DibNo)
[Delphi]   [ Boolean = ]imagekitcontrolname.Effect.StartDibAccess(hDib: THandle; var DibNo: Smallint)

Parameters

Name Explanation
hDib The raster image memory handle (supports 1, 4, 8, 16. 24, and 32 bit images)
DibNo The parameter that retrieves the identification number of the hDIB

Return Value

Returns True if successful, otherwise returns False.

Explanation

The StartDibAccess method is used to allow access to pixels in the Device Independent Bitmap (DIB). This method is to be used in conjunction with the EndDibAccess method. The DibNo is the identification number of the hDib used by the GetDibPixel, SetDibPixel, and EndDibAccess methods.

To access the DIB and manipulate pixel data, you must use the following methods as a group:
StartDibAccess
      |
GetDibPixel, SetDibPixel
      |
EndDibAccess

Note: If you want to access the DIB it is highly recommended that you use the ImageKit DLL functions which are faster.

Sample Code
The following code starts access to the DIB, then loops through each pixel in the image, using the GetDibPixel method to retrieve the pixels' rgb values. Then those values are reversed and set using the SetDibPixel method. (For 1, 16, 24, or 32 bit images)

In C++Builder
   bool Ret;
   short DibNo;
   int i, j;
   Byte PalNo, Red, Green, Blue;

   VImageKit1->LayerNo = -1;
   Ret = VImageKit1->GetImageType();
   if (Ret == false) return;
   Ret = VImageKit1->Effect->StartDibAccess(VImageKit1->ImageHandle, DibNo);
   if (Ret == false) return;

   for (i = 0; i < VImageKit1->ImageHeight; i++)
   {
      for (j = 0; j < VImageKit1->ImageWidth; j++)
      {
         Ret = VImageKit1->Effect->GetDibPixel(DibNo, j, i, PalNo, Red, Green, Blue);
         if (VImageKit1->BitCount == 1)
         {
            if (PalNo != 0)
               PalNo = 0;
            else
               PalNo = 1;
         } else if (VImageKit1->BitCount > 8) {
            Blue = 255 - Blue;
            Green = 255 - Green;
            Red = 255 - Red;
         }
         Ret = VImageKit1->Effect->SetDibPixel(DibNo, j, i, PalNo, Red, Green, Blue);
      }
   }
   Ret = VImageKit1->Effect->EndDibAccess(DibNo);

   VImageKit1->Refresh();

In Delphi
   Ret: Boolean;
   DibNo: Smallint;
   i, j: Longint;
   PalNo, Red, Green, Blue: Byte;

   VImageKit1.LayerNo := -1;
   Ret := VImageKit1.GetImageType();
   if Ret = False then Exit;
   Ret := VImageKit1.Effect.StartDibAccess(ImageKit1.ImageHandle, DibNo);
   if Ret = False then Exit;

   for i := 0 to VImageKit1.ImageHeight - 1 do
   begin
      for j := 0 to VImageKit1.ImageWidth - 1 do
      begin
         Ret := VImageKit1.Effect.GetDibPixel(DibNo, j, i, PalNo, Red, Green, Blue);
         if VImageKit1.BitCount = 1 then
         begin
            if PalNo <> 0 then
               PalNo := 0
            else
               PalNo := 1;
         end
         else if VImageKit1.BitCount > 8 then
         begin
            Blue := 255 - Blue;
            Green := 255 - Green;
            Red := 255 - Red;
         end;
         Ret := VImageKit1.Effect.SetDibPixel(DibNo, j, i, PalNo, Red, Green, Blue);
      end;
   end;
   Ret := VImageKit1.Effect.EndDibAccess(DibNo);

   VImageKit1.Refresh;

The ImageKit10 VCL is a product created by Newtone Corporation