flat assembler
Message board for the users of flat assembler.

Index > Windows > mmx & dib, nned help

Author
Thread Post new topic Reply to topic
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 21 Nov 2005, 09:35
hi, i trying to copy from one monochrome image to second by mask with changing color (painting custom bitmap font on various background with coloring), but i get invalid color, what i am doing wrong?

ps. monochrome background color is black, foreground color is white

Code:
                        mov             eax,[hBits2] ; ppvBits of bitmap font
                        mov             ecx,[hBits1] ; ppvBits of background
                        movq    mm0,[eax]
                        movq    mm1,[ecx]
                        pxor    mm2,mm2
                        pcmpeqd mm2,mm0 ; create mask

; problem here
                        mov             eax,0FFFFFFh ; color
                        movd    mm6,eax
                        punpckldq mm6,mm6

                        pmullw  mm0,mm6
                        psrlw   mm0,8
; end of problem

                        pand    mm1,mm2
                        por             mm1,mm0
                        movq    [ecx],mm1
    

_________________
[not enough memory]
Post 21 Nov 2005, 09:35
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 22 Nov 2005, 08:17
does anybody knows how to create mask of pixel? it is equivalent of: pcmpeqd mm2,mm0
Post 22 Nov 2005, 08:17
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 22 Nov 2005, 09:28
i speak with myself Smile i created mask of pixel with this code, but i don't know how to change color :\

Code:
                        and             eax,0x80808080
                        mov             ecx,eax
                        mov             ebx,eax
                        shr             ebx,7
                        sub             eax,ebx
                        or              eax,ecx
    
Post 22 Nov 2005, 09:28
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 22 Nov 2005, 09:43
try to be more specific...

what is input format (monochrome color), and what is output format (coloured pixel)?
Post 22 Nov 2005, 09:43
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 22 Nov 2005, 12:34
yes, you are right, as i said monochrome background color is black, foreground color is white, background color (black) i want to replace with output backimage (it's done) and foreground color (white) i want to color with my color (not done, i don't know how)


Description: example of font char
Filesize: 689 Bytes
Viewed: 3822 Time(s)

example_of_font_char.jpg


Description: what i want
Filesize: 1.24 KB
Viewed: 3822 Time(s)

what_i_want.jpg


Description: what i have now
Filesize: 1.21 KB
Viewed: 3822 Time(s)

what_i_have_now.jpg



_________________
[not enough memory]
Post 22 Nov 2005, 12:34
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 24 Nov 2005, 09:36
this code i have now (see picture #3), how to change the color? please help Smile

Code:
        mov             edi,[hBits1] ; background picture
        mov             esi,[hBits2] ; font picture
        mov             edx,[edi]
        mov             eax,[esi]

        or              eax,eax
        jz              skip

        ; create mask of font picture pixel
        and             eax,0x80808080
        mov             ecx,eax
        mov             ebx,eax
        shr             ebx,7
        sub             eax,ebx
        or              eax,ecx
        
        ; create pixel from mask (eax - mask)
        or              edx,eax

skip:
        ; store result
        mov             [edi],edx
    
Post 24 Nov 2005, 09:36
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20453
Location: In your JS exploiting you and your system
revolution 24 Nov 2005, 10:03
IF:
eax=mask for white
ebx=background pixels (i assume 4 pixels per dword)
ecx=desired forground pixels
THEN:
Code:
mov edx,ebx
and edx,eax
not eax ;invert the mask
mov edi,ecx
and edi,eax
not eax ;restore mask for next iteration
or  edx,edi ;<-- the new pixel data is here now    
Post 24 Nov 2005, 10:03
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.