...Hey all,
I've been experimenting with ASM in C++, but whenever I use it in my DLL, I can't call any of the functions in the DLL :P
Here's the source
I also have a feeling the ASM is wrong (it should stop looping when ecx = 0...) Help please?Code:#include <windows.h> #ifndef _RWSTD_NO_NAMESPACE using namespace std; #endif extern "C" { INT CALLBACK _export ColorBlend(LONG BlendColor, HBITMAP BitmapHandle); } int LibMain() { return 1; } INT CALLBACK _export ColorBlend(LONG BlendColor, HBITMAP BitmapHandle) { BYTE rBit; BYTE gBit; BYTE bBit; BYTE* Bits = NULL; rBit = RedOf(BlendColor); gBit = GreenOf(BlendColor); bBit = BlueOf(BlendColor); Bits = new BYTE[32*32*3]; GetBitmapBits(BitmapHandle, 32*32*3, Bits); _asm { mov esi,Bits mov ecx,32*32 mov ah,0 mov dh,0 @MixColors: mov al,[esi] mov dl,rBit add ax,dx sar ax,1 mov [esi],al mov al,[esi+1] mov dl,gBit add ax,dx sar ax,1 mov [esi+1],al mov al,[esi+2] mov dl,bBit add ax,dx sar ax,1 mov [esi+2],al add esi,3 ; add ecx,-1 - Taken out thanks to Kedaman's advice (i forgot loop auto-decreases ecx... loop @MixColors } SetBitmapBits(BitmapHandle, 32*32*3, Bits); delete(Bits); return 1; }
Oh, and RedOf, GreenOf, BlueOf functions I use:
Thanks alot! Also, if any of the code is wrong for Alphablending a picture with BlendColor by 50%, please can someone correct it??Code:BYTE RedOf(LONG inColor) { return (byte)(inColor & 255); } BYTE GreenOf(LONG inColor) { return (byte)((inColor >> 8) & 255); } BYTE BlueOf(LONG inColor) { return (byte)(inColor >> 16); }





Reply With Quote