This function sets the RGB value and the palette number of a specified pixel in the Device Independent Bitmap (DIB).

[C++Builder]   BOOL IKSetDibPixel(PTR_IKDIB_INFO stpDibInfo, long lx, long ly);
[Delphi]   function IKSetDibPixel(var stpDibInfo: IKDIB_INFO: lx, ly: Longint): LongBool;

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 IKSetDibPixel function sets the RGB value and the palette number of a specified pixel in the Device Independent Bitmap (DIB). For images that are 1, 4, or 8 bit, set the PalNo into the stpDipInfo parameter. Fo 16, 24, or 32 bit images, set the appropriate Red, Green, and Blue vales in the stpDipInfo parameter.

This function is to be used in conjunction with the IKStartDibAccess function. If successful, the appropriate values are set in the ucPal, ucRed, ucGreen, and ucBlue members of the IKDIB_INFO structure.

For more information about IKDIB_INFO, please refer to the explanation of the IKDIB_INFO member variables at the beginning of the Ik10Effect.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);

 

The ImageKit10 VCL is a product created by Newtone Corporation