Thread Rating:
  • 4 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Transparent Background for Text
#1
[Image: transparenttext.jpg]

Being, bored + seeing how the NTSD skin(yes I follow the progress, because it is the only mod which is making progress) is getting ruined by non transparent text, I decided to make this :).

Code:
.data
hDC dd ?

.code
draw_text proc
    
var_4           = dword ptr -4
lpString        = dword ptr  4
arg_4           = dword ptr  8
arg_8           = dword ptr  0Ch
arg_C           = dword ptr  10h

                push    esi
                mov     esi, [esp+4+lpString]
                mov     eax, [esi]
                mov     edx, [eax+44h]
                push    edi
                lea     ecx, [esp+8+lpString]
                push    ecx
                push    esi
                call    edx   ;Magic Call #1
                mov     edi, eax
                test    edi, edi
                jl      short loc_4012FC
                mov     eax, [esp+0Ch+arg_4]
                mov     ecx, [esp+0Ch]
                push    ebx
                push    TRANSPARENT             ; mode
                push    ecx             ; HDC
                mov        hDC, ecx
                call    ds:SetBkMode
                mov     edx, [esp+10h+arg_8]
                mov     eax, [esp+10h]
                push    edx             ; COLORREF
                push    eax             ; HDC
                call    ds:SetTextColor
                mov     ebx, [esp+10h+lpString]
                push    ebx             ; lpString
                call    ds:lstrlenA
                mov     ecx, [esp+24h]
                mov     edx, [esp+10h+arg_C]
                push    eax             ; int
                mov     eax, [esp+14h]
                push    ebx             ; LPCSTR
                push    ecx             ; int
                push    edx             ; int
                push    eax             ; HDC
                call    ds:TextOutA
                mov     edx, [esp+10h]
                mov     ecx, [esi]
                mov     eax, [ecx+68h]
      
                push    edx
                push    esi
                call    eax    ; Magic Call 2
                mov     eax, edi
                pop     ebx
                

loc_4012FC:                             ; CODE XREF: sub_401290+17j
                pop     edi
                pop     esi

    
    ret

draw_text endp

in rarara.asm, add(at the top bit, you should be able to figure it out) :
Code:
include \masm32\include\gdi32.inc
includelib \masm32\lib\gdi32.lib

Now there are two ways of using this. Patching every line of text that you want to be transparent (useful if you want the majority of your text to still have a background) or completely replacing the real function with your one.

#1:
;makes the background of the first line in the credits transparent
invoke CallPatch,004272C2h, addr draw_text

#2:
;i haven't tested this, should make all text transparent
invoke JmpPatch,00401290h, addr draw_text

Enjoy.
[Image: doty7Xn.gif]

10 ʏᴇᴀʀs sɪɴᴄᴇ ɪʀᴄ ɢᴏᴏᴅ.ɪ ᴡᴀʟᴋ ᴛʜʀᴏᴜɢʜ ᴛʜᴇ ᴇᴍᴘᴛʏ sᴛʀᴇᴇᴛs ᴛʀʏɪɴɢ ᴛᴏ ᴛʜɪɴᴋ ᴏғ sᴏᴍᴇᴛʜɪɴɢ ᴇʟsᴇ ʙᴜᴛ ᴍʏ ᴘᴀᴛʜ ᴀʟᴡᴀʏs ʟᴇᴀᴅs ᴛᴏ ᴛʜᴇ ɪʀᴄ. ɪ sᴛᴀʀᴇ ᴀᴛ ᴛʜᴇ sᴄʀᴇᴇɴ ғᴏʀ ʜᴏᴜʀs ᴀɴᴅ ᴛʀʏ ᴛᴏ sᴜᴍᴍᴏɴ ᴛʜᴇ ɢᴏᴏᴅ ɪʀᴄ. ɪ ᴡᴀᴛᴄʜ ᴏᴛʜᴇʀ ɪʀᴄ ᴄʜᴀɴɴᴇʟs ʙᴜᴛ ɪᴛ ɪs ɴᴏ ɢᴏᴏᴅ. ɪ ᴘᴇsᴛᴇʀ ᴢᴏʀᴛ ᴀɴᴅ ᴛʀʏ ᴛᴏ ʀᴇsɪsᴛ ʜɪs sᴇxɪɴᴇss ʙᴜᴛ ɪᴛ ɪs ᴀʟʟ ᴍᴇᴀɴɪɴɢʟᴇss. ᴛʜᴇ ᴇɴᴅ ɪs ɴᴇᴀʀ.ɪ ᴛʜᴇɴ ᴜsᴜᴀʟʟʏ ʀᴇᴀᴅ sᴏᴍᴇ ᴏʟᴅ ɪʀᴄ ʟᴏɢs ᴀɴᴅ ᴄʀʏ ᴍʏsᴇʟғ ᴛᴏ sʟᴇᴇᴘ.


Reply
Thanks given by:
#2
waitttttttttttttt.................
thats awesome
you found how to make text bmps (in the exe) in to pngs (trasparency)

if you can do this getting 2.0 to load pngs shouldn't be tough
Reply
Thanks given by:
#3
No...
[Image: whatimean.jpg]

That is what I'm talking about(the blue background around the letters). Those little things really annoy me :). Nothing to do with bmps, pngs, transparency or anything really.
[Image: doty7Xn.gif]

10 ʏᴇᴀʀs sɪɴᴄᴇ ɪʀᴄ ɢᴏᴏᴅ.ɪ ᴡᴀʟᴋ ᴛʜʀᴏᴜɢʜ ᴛʜᴇ ᴇᴍᴘᴛʏ sᴛʀᴇᴇᴛs ᴛʀʏɪɴɢ ᴛᴏ ᴛʜɪɴᴋ ᴏғ sᴏᴍᴇᴛʜɪɴɢ ᴇʟsᴇ ʙᴜᴛ ᴍʏ ᴘᴀᴛʜ ᴀʟᴡᴀʏs ʟᴇᴀᴅs ᴛᴏ ᴛʜᴇ ɪʀᴄ. ɪ sᴛᴀʀᴇ ᴀᴛ ᴛʜᴇ sᴄʀᴇᴇɴ ғᴏʀ ʜᴏᴜʀs ᴀɴᴅ ᴛʀʏ ᴛᴏ sᴜᴍᴍᴏɴ ᴛʜᴇ ɢᴏᴏᴅ ɪʀᴄ. ɪ ᴡᴀᴛᴄʜ ᴏᴛʜᴇʀ ɪʀᴄ ᴄʜᴀɴɴᴇʟs ʙᴜᴛ ɪᴛ ɪs ɴᴏ ɢᴏᴏᴅ. ɪ ᴘᴇsᴛᴇʀ ᴢᴏʀᴛ ᴀɴᴅ ᴛʀʏ ᴛᴏ ʀᴇsɪsᴛ ʜɪs sᴇxɪɴᴇss ʙᴜᴛ ɪᴛ ɪs ᴀʟʟ ᴍᴇᴀɴɪɴɢʟᴇss. ᴛʜᴇ ᴇɴᴅ ɪs ɴᴇᴀʀ.ɪ ᴛʜᴇɴ ᴜsᴜᴀʟʟʏ ʀᴇᴀᴅ sᴏᴍᴇ ᴏʟᴅ ɪʀᴄ ʟᴏɢs ᴀɴᴅ ᴄʀʏ ᴍʏsᴇʟғ ᴛᴏ sʟᴇᴇᴘ.


Reply
Thanks given by:
#4
i noe
that blue background

its like when lf2 types the letters it's pasting the letters with a blue background together

so you can say they are bmps - a.bmp b.bmp c.bmp d.bmp e.bmp etc

so you like changed it to pngs - a.png b.png c.png d.png e.png etc

so its the same pic but with transparency
(atleast my logic)

i wonder if you can get 2.0 to load pngs (it will help ntsd2 (they needed alpha transparency before))
Reply
Thanks given by:
#5
naruto, you have absolutely no clue how that works and are talking random wrong sh*t... that stuff is all we need, thanks alot silva^^
Reply
Thanks given by:
#6
not working for me 0.o

i put the .code part in generic.inc's .code part
and .data part in generic.inc's .data part
and the
    ASM-Code:
.data
hDC dd ?
 
.code
draw_text proc
 
var_4           = dword ptr -4
lpString        = dword ptr  4
arg_4           = dword ptr  8
arg_8           = dword ptr  0Ch
arg_C           = dword ptr  10h
 
                push    esi
                mov     esi, [esp+4+lpString]
                mov     eax, [esi]
                mov     edx, [eax+44h]
                push    edi
                lea     ecx, [esp+8+lpString]
                push    ecx
                push    esi
                call    edx   ;Magic Call #1
                mov     edi, eax
                test    edi, edi
                jl      short loc_4012FC
                mov     eax, [esp+0Ch+arg_4]
                mov     ecx, [esp+0Ch]
                push    ebx
                push    TRANSPARENT             ; mode
                push    ecx             ; HDC
                mov        hDC, ecx
                call    ds:SetBkMode
                mov     edx, [esp+10h+arg_8]
                mov     eax, [esp+10h]
                push    edx             ; COLORREF
                push    eax             ; HDC
                call    ds:SetTextColor
                mov     ebx, [esp+10h+lpString]
                push    ebx             ; lpString
                call    ds:lstrlenA
                mov     ecx, [esp+24h]
                mov     edx, [esp+10h+arg_C]
                push    eax             ; int
                mov     eax, [esp+14h]
                push    ebx             ; LPCSTR
                push    ecx             ; int
                push    edx             ; int
                push    eax             ; HDC
                call    ds:TextOutA
                mov     edx, [esp+10h]
                mov     ecx, [esi]
                mov     eax, [ecx+68h]
 
                push    edx
                push    esi
                call    eax    ; Magic Call 2
                mov     eax, edi
                pop     ebx
 
 
loc_4012FC:                             ; CODE XREF: sub_401290+17j
                pop     edi
                pop     esi
 
 
    ret
 
draw_text endp


and this
include \masm32\include\gdi32.inc
includelib \masm32\lib\gdi32.lib
in rarara. asm top part (they were toghether)

and these

#1:
;makes the background of the first line in the credits transparent
invoke CallPatch,004272C2h, addr draw_text

#2:
;i haven't tested this, should make all text transparent
invoke JmpPatch,00401290h, addr draw_text

tried both not working
Reply
Thanks given by:
#7
Works fine for: me, Nave, 1477. What doesn't work? You can't assemble the dll? If so what error do you get.

Doesn't work in game? Are you sure you are using the correct exe?

Kind of hard to help you, when all you say is "its not working"
[Image: doty7Xn.gif]

10 ʏᴇᴀʀs sɪɴᴄᴇ ɪʀᴄ ɢᴏᴏᴅ.ɪ ᴡᴀʟᴋ ᴛʜʀᴏᴜɢʜ ᴛʜᴇ ᴇᴍᴘᴛʏ sᴛʀᴇᴇᴛs ᴛʀʏɪɴɢ ᴛᴏ ᴛʜɪɴᴋ ᴏғ sᴏᴍᴇᴛʜɪɴɢ ᴇʟsᴇ ʙᴜᴛ ᴍʏ ᴘᴀᴛʜ ᴀʟᴡᴀʏs ʟᴇᴀᴅs ᴛᴏ ᴛʜᴇ ɪʀᴄ. ɪ sᴛᴀʀᴇ ᴀᴛ ᴛʜᴇ sᴄʀᴇᴇɴ ғᴏʀ ʜᴏᴜʀs ᴀɴᴅ ᴛʀʏ ᴛᴏ sᴜᴍᴍᴏɴ ᴛʜᴇ ɢᴏᴏᴅ ɪʀᴄ. ɪ ᴡᴀᴛᴄʜ ᴏᴛʜᴇʀ ɪʀᴄ ᴄʜᴀɴɴᴇʟs ʙᴜᴛ ɪᴛ ɪs ɴᴏ ɢᴏᴏᴅ. ɪ ᴘᴇsᴛᴇʀ ᴢᴏʀᴛ ᴀɴᴅ ᴛʀʏ ᴛᴏ ʀᴇsɪsᴛ ʜɪs sᴇxɪɴᴇss ʙᴜᴛ ɪᴛ ɪs ᴀʟʟ ᴍᴇᴀɴɪɴɢʟᴇss. ᴛʜᴇ ᴇɴᴅ ɪs ɴᴇᴀʀ.ɪ ᴛʜᴇɴ ᴜsᴜᴀʟʟʏ ʀᴇᴀᴅ sᴏᴍᴇ ᴏʟᴅ ɪʀᴄ ʟᴏɢs ᴀɴᴅ ᴄʀʏ ᴍʏsᴇʟғ ᴛᴏ sʟᴇᴇᴘ.


Reply
Thanks given by:
#8
i used the newest exe to load the dll when i build it doesn't work

am i suppose to modify the "?"
in hDC dd ? because i didn't and its not working

i.e not making background transparent
Reply
Thanks given by:
#9
(07-22-2009, 12:53 PM)naruto hyuuga Wrote:  i used the newest exe to load the dll when i build it doesn't work

am i suppose to modify the "?"
in hDC dd ? because i didn't and its not working

i.e not making background transparent

rarara.asm:


Code:
; Based on Masm32 Dll Plugin Example for Damnation by Drakken
; Modified for LF2 by Silva
; Contributions by: genevrier

.386
.Model Flat, StdCall
OPTION CASEMAP :NONE

include \masm32\include\windows.inc
include \masm32\include\gdi32.inc
include \masm32\include\masm32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib

include rarara.inc
include generic.inc

.code

DllEntryPoint proc hInstDLL:DWORD, reason:DWORD, unused:DWORD


    mov eax,reason
    .if eax == DLL_PROCESS_ATTACH                                            ; Called when our dll loaded
        call DLLStartup                                                        ; Memory patches and jmp patches
        
        .elseif reason == DLL_PROCESS_DETACH
        push NULL
        call PostQuitMessage

    .endif
    ret

DllEntryPoint endp

DLLStartup proc

; Here you can put the patches you want to use when the dll loads
; Also you should put all your jump patches here
    

invoke JmpPatch,00401290h, addr draw_text
    ret

DLLStartup endp

End DllEntryPoint

generic.inc:
Code:
.data
hDC dd ?

.code
draw_text proc

var_4           = dword ptr -4
lpString        = dword ptr  4
arg_4           = dword ptr  8
arg_8           = dword ptr  0Ch
arg_C           = dword ptr  10h

                push    esi
                mov     esi, [esp+4+lpString]
                mov     eax, [esi]
                mov     edx, [eax+44h]
                push    edi
                lea     ecx, [esp+8+lpString]
                push    ecx
                push    esi
                call    edx   ;Magic Call #1
                mov     edi, eax
                test    edi, edi
                jl      short loc_4012FC
                mov     eax, [esp+0Ch+arg_4]
                mov     ecx, [esp+0Ch]
                push    ebx
                push    TRANSPARENT             ; mode
                push    ecx             ; HDC
                mov        hDC, ecx
                call    ds:SetBkMode
                mov     edx, [esp+10h+arg_8]
                mov     eax, [esp+10h]
                push    edx             ; COLORREF
                push    eax             ; HDC
                call    ds:SetTextColor
                mov     ebx, [esp+10h+lpString]
                push    ebx             ; lpString
                call    ds:lstrlenA
                mov     ecx, [esp+24h]
                mov     edx, [esp+10h+arg_C]
                push    eax             ; int
                mov     eax, [esp+14h]
                push    ebx             ; LPCSTR
                push    ecx             ; int
                push    edx             ; int
                push    eax             ; HDC
                call    ds:TextOutA
                mov     edx, [esp+10h]
                mov     ecx, [esi]
                mov     eax, [ecx+68h]

                push    edx
                push    esi
                call    eax    ; Magic Call 2
                mov     eax, edi
                pop     ebx


loc_4012FC:                             ; CODE XREF: sub_401290+17j
                pop     edi
                pop     esi


    ret

draw_text endp

I've also attached the compiled dll, which I tested with the new exe, and it works perfectly. If you still can't get it to work, just give up.


Attached Files
.rar   rarara.rar (Size: 868 bytes / Downloads: 92)
[Image: doty7Xn.gif]

10 ʏᴇᴀʀs sɪɴᴄᴇ ɪʀᴄ ɢᴏᴏᴅ.ɪ ᴡᴀʟᴋ ᴛʜʀᴏᴜɢʜ ᴛʜᴇ ᴇᴍᴘᴛʏ sᴛʀᴇᴇᴛs ᴛʀʏɪɴɢ ᴛᴏ ᴛʜɪɴᴋ ᴏғ sᴏᴍᴇᴛʜɪɴɢ ᴇʟsᴇ ʙᴜᴛ ᴍʏ ᴘᴀᴛʜ ᴀʟᴡᴀʏs ʟᴇᴀᴅs ᴛᴏ ᴛʜᴇ ɪʀᴄ. ɪ sᴛᴀʀᴇ ᴀᴛ ᴛʜᴇ sᴄʀᴇᴇɴ ғᴏʀ ʜᴏᴜʀs ᴀɴᴅ ᴛʀʏ ᴛᴏ sᴜᴍᴍᴏɴ ᴛʜᴇ ɢᴏᴏᴅ ɪʀᴄ. ɪ ᴡᴀᴛᴄʜ ᴏᴛʜᴇʀ ɪʀᴄ ᴄʜᴀɴɴᴇʟs ʙᴜᴛ ɪᴛ ɪs ɴᴏ ɢᴏᴏᴅ. ɪ ᴘᴇsᴛᴇʀ ᴢᴏʀᴛ ᴀɴᴅ ᴛʀʏ ᴛᴏ ʀᴇsɪsᴛ ʜɪs sᴇxɪɴᴇss ʙᴜᴛ ɪᴛ ɪs ᴀʟʟ ᴍᴇᴀɴɪɴɢʟᴇss. ᴛʜᴇ ᴇɴᴅ ɪs ɴᴇᴀʀ.ɪ ᴛʜᴇɴ ᴜsᴜᴀʟʟʏ ʀᴇᴀᴅ sᴏᴍᴇ ᴏʟᴅ ɪʀᴄ ʟᴏɢs ᴀɴᴅ ᴄʀʏ ᴍʏsᴇʟғ ᴛᴏ sʟᴇᴇᴘ.


Reply
Thanks given by:
#10
naruto you're supposed to describe your problem (ie what exactly happens/doesn't work).
Quote of the Day f***ing Year (Click to View)
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)