Author Topic: FloodFill / Clipping (GDImage64 version 7.10)  (Read 2008 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1980
    • zapsolution
FloodFill / Clipping (GDImage64 version 7.10)
« on: January 11, 2022, 05:25:06 pm »
This VS2019 project, is based on GDImage64 version 7.10,

The coloring functions of GDI32 ExtFoodFill and GetPixel are working only in 24-bit RGB colors, without alpha channel.

To work around this limitation, here is a project that illustrates the clipping functions of GDImage64.
The principle is the same as in PhotoShop, a checkerboard is used in the background to visualize the transparent areas.
All fill and pixel selection functions work in 32-bit mode (with alpha channel).
When filling it is possible to use a tolerance factor, which allows to remove the artifacts caused by the jpeg compression.
Note: Cropped images must be saved in PNG format to preserve transparency.

About the interface:
It is entirely done with 2 GDImage controls, one for the work area (with the image),
the other containing the controls:
- The color selector, which allows you to use either a color picker or a combo box to choose the desired color.
- 2 vertical sliders, one to choose the level of transparency, the other for the filling tolerance.
- Several icons to choose or save an image, or cancel the modifications.
- Information concerning the coordinates of the cursor, as well as the color of the pixel flown over with its components A, R, G, B.




New in version 7.10

void zDetectDeviceAudio(IN HWND hWnd);
Populate a ComboBox or a ListBox with the name of available audio devices.

void zDetectDeviceVideo(IN HWND hWnd);
Populate a ComboBox or a ListBox with the name of available video devices.

WCHAR* ZI_SpinnerGetTime();
Get a formated string (HH:MM:SS) matching the spinner ellapsed time.

void ZI_SetHdcColorAlpha(IN HDC hDC, IN long Color, IN BYTE Alpha);
Use the HDC of a selected bitmap, to change the alpha channel of a specific color.

void ZI_SetBitmapColorAlpha(IN HBITMAP hBmp, IN long Color, IN BYTE Alpha);
Use a HBITMAP handle, to change the alpha channel of a specific color.

HBITMAP CropBitmapToBound(IN HBITMAP hBmp);
Clip all pixels using a null alpha channel.

HBITMAP ZI_CropBitmapColorToBound(IN HBITMAP hBmp, IN DWORD ARGBcolor);
Clip all pixels matching a specific Alpha, red, green, blue color.

void ZI_LinearFlood (IN HDC hDC, IN long x, IN long y, IN DWORD FillColor, IN long Tolerance);
This procedure fills an area of the display surface (HDC) with the FillColor,
using x-y coordinates for seed point (SeedColor and FillColor must be different).
The Tolerance is to consider the pixels within a specific range to match the SeedColor.

DWORD ZI_GetPixel(IN HDC hDC, IN long x, IN long y);
This is a 32-bit replacement for the 24-bit only GetPixel API, returning a color including the alpha channel.

HBITMAP ZI_CreateTileBitmap(IN WCHAR* szFileToTile, IN long Xin, IN long Yin, IN WORD nBitCount);
Create a specific 24 or 32-bit (nBitCount) tiled bitmap using a source file image to paint the Xin/Yin area of the resulting HBITMAP.

DWORD ZD_GetBitmapPixel(IN long nID, IN long x, IN long y);
Get the Alpha,red,green,blue color of a specific nID sprite object.

void ZD_LinearFlood(IN long nID, IN long x, IN long y, IN DWORD FillColor, IN long Tolerance);
This procedure fills an area of a specific nID sprite object with the FillColor,
using x-y coordinates as seed point (SeedColor and FillColor must be different).
The Tolerance is to consider the pixels within a specific range to match the SeedColor.
« Last Edit: January 17, 2022, 11:13:30 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)