I did it. My guess seems to be correct. Uniscribe seems to draw transparent characters on top of images transferred via BitBlt.
USING: accessors alien.c-types alien.data colors images.viewer io io.encodings.string io.encodings.utf16n io.styles kernel literals math sequences ui ui.commands ui.gadgets ui.gadgets.borders ui.gadgets.panes ui.gadgets.tracks ui.gestures windows.gdi32 windows.offscreen windows.ole32 windows.types windows.usp10 locals fonts windows.fonts windows.errors ; IN: hello-uniscribe ! NOTE: The following declarations are required in gdi32.factor ! ! FUNCTION: int SetBkMode ( HDC hdc, int iBkMode ) ! FUNCTION: BOOL BitBlt ( HDC hdc, int x, int y, int cx, int cy, HDC hdcSrc, int x1, int y1, DWORD rop ) TUPLE: hello-gadget < track ; : <hello-gadget> ( -- gadget ) horizontal hello-gadget new-track [ { { font-size 24 } } [ "Hello" print "Grüß dich" print "здравствуйте" print "こんにちは" print "안녕하세요" print "שָׁלוֹם " print ] with-style ] make-pane { 10 10 } <border> f track-add ; :: com-screen-shot ( gadget -- ) [ :> dc gadget dim>> dc [ dc 0 0 gadget dim>> first2 gadget parent>> handle>> hDC>> 0 0 SRCCOPY BitBlt drop ] make-bitmap-image image-window ] with-memory-dc ; CONSTANT: ssa-dwFlags flags{ SSA_GLYPHS SSA_FALLBACK SSA_TAB } :: (com-screen-shot-with-text) ( gadget dim bkMode uOptions -- ) [ :> dc dim dc [ dc sans-serif-font cache-font SelectObject win32-error=0/f dc T{ rgba f 0.0 1.0 1.0 0.0 } color>RGB SetBkColor drop dc T{ rgba f 0.0 0.0 1.0 1.0 } color>RGB SetTextColor drop dc bkMode SetBkMode drop dc 0 0 dim first2 gadget parent>> handle>> hDC>> 0 0 SRCCOPY BitBlt drop dc "Hello!" [ utf16n encode ] ! pString [ length ] bi ! cString dup 1.5 * 16 + >integer ! cGlyphs -- MSDN says this is "recommended size" -1 ! iCharset -- Unicode ssa-dwFlags 0 ! iReqWidth f ! psControl f ! psState f ! piDx f ! pTabdef f ! pbInClass f void* <ref> ! pssa [ ScriptStringAnalyse ] keep [ check-ole32-error ] [ |ScriptStringFree void* deref ] bi* 0 ! iX 0 ! iY uOptions { 0 0 } dim <RECT> 0 ! iMinSel 0 ! iMaxSel FALSE ! fDisabled ScriptStringOut check-ole32-error ] make-bitmap-image image-window ] with-memory-dc ; : com-screen-shot-with-text-opaque ( gadget -- ) dup dim>> OPAQUE ETO_OPAQUE (com-screen-shot-with-text) ; : com-screen-shot-with-text-transparent-1 ( gadget -- ) dup dim>> OPAQUE 0 (com-screen-shot-with-text) ; : com-screen-shot-with-text-transparent-2 ( gadget -- ) dup dim>> TRANSPARENT ETO_OPAQUE (com-screen-shot-with-text) ; : com-screen-shot-with-text-transparent-3 ( gadget -- ) dup dim>> TRANSPARENT 0 (com-screen-shot-with-text) ; hello-gadget "gestures" f { { T{ key-down { sym "1" } } com-screen-shot } { T{ key-down { sym "2" } } com-screen-shot-with-text-opaque } { T{ key-down { sym "3" } } com-screen-shot-with-text-transparent-1 } { T{ key-down { sym "4" } } com-screen-shot-with-text-transparent-2 } { T{ key-down { sym "5" } } com-screen-shot-with-text-transparent-3 } } define-command-map MAIN-WINDOW: hello-uniscribe { { title "გამარჯობა, uniscribe" } } <hello-gadget> >>gadgets ; > 2019/05/28 19:07、KUSUMOTO Norio <kusum...@na.rim.or.jp>のメール: > > Hi Alexander, > > >> 2019/05/28 15:20、Alexander Ilin <ajs...@yandex.ru>のメール: >> >> Is it possible to tell Uniscribe to render the text in white color? >> If such text shows up on the black background, that would confirm part of >> the theory. > > Nice Idea. > I modified the code to whiten the device context given by with-memory-dc > using PatBlt. > Uniscribe works well with transparent background text. > The next step should be to use BitBlt. -- KUSUMOTO Norio _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk