This function retrieves the RGB values and palette number of the specified pixel in the Device Independent Bitmap (DIB).

[C++Builder/Visual C++]     BOOL IKGetDibPixel(PTR_IKDIB_INFO stpDibInfo, long lx, long ly);
[Delphi]         function IKGetDibPixel(var stpDibInfo: IKDIB_INFO: lx, ly: Longint): LongBool;
[Visual Basic]   Function IKGetDibPixel(stpDibInfo As IKDIB_INFO, ByVal lx As Long, ByVal ly As Long) As Long

Parameters

Name Explanation
stpDibInfo A structure variable (user-defined type) as retrieved by the IKStartDibAccess function
lx, ly The x,y coordinates of the specified pixel

Return Value

Returns True (nonzero) if successful. Returns False (0) if unsuccessful.

Explanation

The IKGetDibPixel function retrieves the RGB values and palette number of the specified pixel in the Device Independent Bitmap (DIB). If successful, for 1, 4, and 8 bit images the Pal is set in the stpDibInfo parameter; for 16, 24, or 32 bit images the Red, Green, and Blue values are set in the stpDibInfo parameter. 

For more information about IKDIB_INFO, please refer to the explanation of the IKDIB_INFO member variables at the beginning of the Ik10Effect.dll, Ik10EffectA.dll, Ik10Effect64.dll, Ik10Effect64A.dll section.


To access the DIB and manipulate pixel data, you must use the following functions as a group.

      IKStartDibAccess

              l

      IKGetDibPixel, IKSetDibPixel

              l

      IKEndDibAccess


Sample Code

The following code starts access to the DIB, then loops through each pixel in the image, using the IKGetDibPixel function to retrieve the pixels' rgb values. Then those values are reversed and set using the IKSetDibPixel function.


(1)Delphi

   Handle: THandle;

   ImageInfo: IKIMAGE_INFO;

   DibInfo: IKDIB_INFO;

   Ret: LongBool;

   i, j: Integer;


   Handle := IKFileLoad('newtone.bmp', 0, 0, 0, 0, nil, nil, nil);

   if Handle = 0 then Exit;

   Ret := IKGetImageType(Handle, ImageInfo);

   Ret := IKStartDibAccess(Handle, DibInfo);


   for i := 0 to ImageInfo.Height - 1 do

   begin

      for j := 0 to ImageInfo.Width - 1 do

      begin

         Ret := IKGetDibPixel(DibInfo, j, i);

         if ImageInfo.BitCount = 1 then

         begin

            if DibInfo.PalNo <> 0 then

               DibInfo.PalNo := 0

            else

               DibInfo.PalNo := 1;

         end

         else if ImageInfo.BitCount > 8 then

         begin

            DibInfo.Blue := 255 - DibInfo.Blue;

            DibInfo.Green := 255 - DibInfo.Green;

            DibInfo.Red := 255 - DibInfo.Red;

         end;

         Ret := IKSetDibPixel(DibInfo, j, i);

      end;

   end;

   Ret := IKEndDibAccess(Handle, DibInfo);


   Ret := IKBmpFileSave('newtone.bmp', Handle, False, 0, nil, nil, nil);

   IKFreeMemory(Handle);


(2)Visual Basic

   Dim Handle As Long

   Dim ImageInfo As IKIMAGE_INFO

   Dim DibInfo As IKDIB_INFO

   Dim Ret As Long

   Dim i As Long, j As Long


   Handle = IKFileLoad("newtone.bmp", 0, 0, 0, 0, "", "", "")

   If Handle = 0 Then Exit Sub

   Ret = IKGetImageType(Handle, ImageInfo)

   Ret = IKStartDibAccess(Handle, DibInfo)


   For i = 0 To ImageInfo.Height - 1

      For j = 0 To ImageInfo.Width - 1

         Ret = IKGetDibPixel(DibInfo, j, i)

         If ImageInfo.BitCount = 1 Then

            If DibInfo.PalNo <> 0 Then

               DibInfo.PalNo = 0

            Else

               DibInfo.PalNo = 1

            End If

         Else If ImageInfo.BitCount > 8 Then

            DibInfo.Blue = 255 - DibInfo.Blue

            DibInfo.Green = 255 - DibInfo.Green

            DibInfo.Red = 255 - DibInfo.Red

         End If

         Ret = IKSetDibPixel(DibInfo, j, i)

      Next j

   Next i

   Ret = IKEndDibAccess(Handle, DibInfo)


   Ret = IKBmpFileSave("newtone.bmp", Handle, False, 0, "", "", "")

   IKFreeMemory(Handle)

 

The ImageKit10 ActiveX is a product created by Newtone Corporation