Results 1 to 7 of 7

Thread: [VB6/Win8+] Using DirectX to show emojis with color

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,363

    Cool [VB6/Win8+] Using DirectX to show emojis with color


    ColorEmojiDemo

    With phones and web browsers, people are getting used to seeing emojis with color everywhere. But disappointingly, the basic Windows GDI functions do not support these, so in VB6 (and Explorer and anywhere using the default old GDI stuff), even when you support Unicode to display emojis, you only see them in black and white. So how do you get them to show in color? One way is using DirectX-- Direct2D and DirectWrite. This is a simple demo that just renders a test string directly onto the form.

    Requirements
    Windows 8.1 or newer - This *may* work if you've got a newer DirectX version on Win7 and have installed update KB2729094, but it's officially documented as 8.1+ only for the critical D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT flag. I've only tested it on my system, which is Windows 10 1809.
    oleexp v6.2 or newer - Only required in the IDE; does not need to be distributed with the compiled .exe. This uses DirectX COM interfaces defined in the oleexp.tlb type library. The trick graciously allowed integrating his d2dvb and dwvb typelibs with oleexp, and I expanded them to include all related interfaces and other DirectX modules. You could likely substitute those with little to no change.

    Notes
    Not all fonts support color emojis, and Windows/DirectX does not support all color font formats. The demo uses Segoe UI, which is a built-in Windows font on newer versions that does. You'll have to check both whether support is there and what format it is for other fonts (any of the preinstalled Windows fonts would be in the right format *if* they are colorized, but 3rd party may be in other formats as Android and Apple platforms support different ones).

    This code is 64-bit ready; you'd just need to add PtrSafe to the APIs (or remove them) and substitute tbShellLib for oleexp. I was originally going to publish it in twinBASIC, but there's currently a bug preventing it from working. Such is the nature of beta software. Look for it soon

    Heavily based on a wonderful demo by Code Doggo on StackOverflow
    For simplicity I've rendered it directly onto a VB form rather than create a dedicated window. In the future, I might make this into an edit control.



    There's now also a twinBASIC version of this project which supports 64bit compilation. Note: Currently only works when compiled.

    twinBASIC DirectX Color Emoji Demo

    What's fun about twinBASIC is you don't need the hacks like ChrW2 to get emojis into a String. You can just use normal string assingments:

    Attached Files Attached Files
    Last edited by fafalone; May 22nd, 2023 at 12:04 AM. Reason: Added additional notes and reqs details

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width