| id | REF-027 | |||||
|---|---|---|---|---|---|---|
| workflow | github | |||||
| github_issue | emulebb/emulebb#92 | |||||
| title | CaptchaGenerator — replace CxImage with ATL CImage / native GDI | |||||
| status | OPEN | |||||
| priority | Minor | |||||
| category | refactor | |||||
| labels |
|
|||||
| milestone | ||||||
| created | 2026-04-10 | |||||
| source | community-0.72 commit 24d1de7 (irwir, 2026-01-05); BUG-008 context |
Workflow status is tracked in GitHub: emulebb/emulebb#92. This local document is retained as an engineering spec/evidence record.
CaptchaGenerator.cpp uses CxImage as its rendering library. CxImage is a legacy
third-party library also used elsewhere in the codebase. Community-0.72 (irwir) removed
this CxImage dependency from CaptchaGenerator and replaced it with ATL CImage / native
GDI in commit 24d1de7. This is a targeted dependency reduction that:
- Removes the
CxImage/xImage.hinclude from the captcha generator - Replaces
CxImagebitmap operations withBITMAPINFO/CreateDIBSection+ GDI - Uses
<atlimage.h>(part of ATL, always available on Windows) for PNG export - Eliminates the
libpngtransitive dependency for captcha output
Note: CxImage may still be used in other parts of the codebase (e.g., image preview
dialogs). This refactor scopes to CaptchaGenerator only.
Source: community-0.72, commit 24d1de7 (January 2026)
Community's rewrite also changes the captcha rendering approach:
- Old: 1bpp palette-indexed CxImage bitmap
- New: 1bpp
BITMAPINFOwithRGBQUADpalette +CreateDIBSection+ native GDI
Community's approach includes fixing several rendering parameters:
CROWDEDSIZEincreased from 18 → 23 (wider letter spacing)- Captcha character set renamed from
schCaptchaContent→sCaptchaCharSet - Cleaner character rendering loop using
SelectObject/DrawText
BUG-008 (CaptchaGenerator rand() & 8 bimodal jitter) documents a separate bug in
the jitter generation: nJitter = rand() & 8 produces only 0 or 8, never 1-7. Community's
full rewrite incidentally eliminates this jitter code (their rendering approach doesn't use
the same jitter pattern). Our targeted fix for BUG-008 should use rand() % 9 or a similar
uniform distribution; the REF-027 rewrite would eliminate it entirely.
If REF-027 lands, close BUG-008 as resolved by refactor.
-
CaptchaGenerator.cppno longer includesCxImage/xImage.h - Captcha bitmap generated using
BITMAPINFO+CreateDIBSectionorATL::CImage - Generated captcha still passes
CUpDownClient::ProcessCaptchaRequestsize checks (height 11-49, width 11-149) - No regression in captcha readability
- If CxImage has no other consumers after this change, remove it entirely (coordinate with a broader CxImage audit)