INCLUDE ..\COMMON\COMMON.INC INCLUDE ..\COMMON\MATH.INC SMART LOCALS .386 .MODEL FLAT RGB888 STRUC PRGB888 TYPEDEF NEAR PTR RGB888 RGB888@@mBlue DB ? RGB888@@mGreen DB ? RGB888@@mRed DB ? ENDS ImageInfo STRUC PImageInfo TYPEDEF NEAR PTR ImageInfo@@mSrcWidth DD ? ImageInfo@@mSrcHeight DD ? ENDS .DATA sOutColIterator DD ? sSrcRow DD ? sDstRow DD ? .CODE _resampleClipRow proc near ; short resampleClip(char *lpIn,char *lpOut,DWORD inLen,DWORD outLen,DWORD outClamp) LOCAL sampleFactor:DWORD,runningFactor:DWORD=LocalLength push ebp ; save stack frame mov ebp,esp ; create new stack frame sub esp,LocalLength ; adjust stack for local push esi ; save source index register push edi ; save destination push ebx ; save ebx register mov eax,[ebp+10h] ; move inLen to eax register cmp eax,0000h ; compare inLen to zero jle @@errorExit ; if it's less or equal then exit mov ebx,[ebp+14h] ; move outLen to ebx register cmp ebx,0000h ; compare outLen to zero jle @@errorExit ; if it's less or equal then exit dec eax ; decrement inLen shl eax,10h ; multiply inLen by 65536L divide eax,ebx ; divide ((inLen-1L)*65536L)/outLen mov sampleFactor,eax ; store the factor dec ebx ; ebx has (outLen-1) mov ecx,ebx ; copy (outLen-1) to ecx mov eax,[ebp+18h] ; move outClip to eax register sub ebx,eax ; subtract (outLen-1L)-outClip, this is clipping region mov edi,[ebp+0Ch] ; move lpOut to destination index register mov eax,size RGB888 ; move sizeof(RGB888) to eax register multiply eax,ecx ; multiply (outLen-1)*sizeof(RGB888) add edi,eax ; edi=lpOut+(outLen-1L) mov esi,[ebp+08h] ; move lpIn to source index register multiply ecx,sampleFactor ; multiply (outLen-1)*sampleFactor mov runningFactor,eax ; save this into runningFactor @@loopControl: ; loop control sync address cmp ecx,0000h ; make sure we're within boundary jl @@exit ; if not then we exit ; cmp ecx,ebx ; compare ecx to clipping region ; je @@exit ; if it's equal then we're done mov eax,runningFactor ; move last running factor into eax round ; round it off mov ebx,size RGB888 ; get size of RGB888 to ebx register multiply eax,ebx ; multiply running factor by sizeof(RGB888) mov dl,byte ptr[esi+eax] ; copy blue into dl mov byte ptr[edi],dl ; copy blue into target mov dl,byte ptr[esi+eax+1] ; copy green into dl mov byte ptr[edi+1],dl ; copy green into target mov dl,byte ptr[esi+eax+2] ; copy red into dl mov byte ptr[edi+2],dl ; copy red into target mov eax,sampleFactor ; move sampleFactor into eax register sub runningFactor,eax ; subtract from running factor dec ecx ; decrement counter sub edi,size RGB888 ; advance (backwards) along lpOut array jmp @@loopControl ; continue processing @@errorExit: ; error exit return sync address xor ax,ax ; clear ax register on error jmp @@endProcedure ; jump to end procedure @@exit: ; exit sync address mov ax,01h ; set ax register on success @@endProcedure: ; end procedure sync address pop ebx ; restore ebx register pop edi ; restore destination index register pop esi ; restore source index register add esp,LocalLength ; remove locals off stack pop ebp ; restore previous stack frame retn ; return near to caller _resampleClipRow endp _resampleClipCol proc near ; short resampleClip(char *lpIn,char *lpOut,DWORD inLen,DWORD inWidth,DWORD outLen,DWORD outWidth,DWORD outClamp) LOCAL sampleFactor:DWORD,runningFactor:DWORD=LocalLength push ebp ; save stack frame mov ebp,esp ; create new stack frame sub esp,LocalLength ; adjust stack for local push esi ; save source index register push edi ; save destination push ebx ; save ebx register mov edx,[ebp+1Ch] ; move outWidth to edx register mov eax,size RGB888 ; move sizeof(RGB888) to eax register multiply eax,edx ; eax=outWidth*sizeof(RGB888) mov sOutColIterator,eax ; save column iterator mov eax,[ebp+10h] ; move inLen to eax register cmp eax,0000h ; compare inLen to zero jle @@errorExit ; if it's less or equal then exit mov ebx,[ebp+18h] ; move outLen to ebx register cmp ebx,0000h ; compare outLen to zero jle @@errorExit ; if it's less or equal then exit dec eax ; decrement inLen shl eax,10h ; multiply inLen by 65536L divide eax,ebx ; divide ((inLen-1L)*65536L)/outLen mov sampleFactor,eax ; store the factor dec ebx ; ebx has (outLen-1) mov ecx,ebx ; copy (outLen-1) to ecx mov eax,[ebp+20h] ; move outClip to eax register sub ebx,eax ; subtract (outLen-1L)-outClip, this is clipping region mov edi,[ebp+0Ch] ; move lpOut to destination index register mov eax,[ebp+1Ch] ; move outWidth to eax register multiply eax,ecx ; multiply (outLen-1)*width mov edx,size RGB888 ; move sizeof(RGB888) to edx multiply eax,edx ; eax has ((outLen-1)*outWidth)*sizeof(RGB888) add edi,eax ; edi=lpOut+((outLen-1)*outWidth)*sizeof(RGB888), points to end of array mov esi,[ebp+08h] ; move lpIn to source index register multiply ecx,sampleFactor ; multiply (outLen-1)*sampleFactor mov runningFactor,eax ; save this into runningFactor @@loopControl: ; loop control sync address cmp ecx,0000h ; make sure we're within boundary jl @@exit ; if not then we exit cmp ecx,ebx ; compare ecx to clipping region je @@exit ; if it's equal then we're done mov eax,runningFactor ; move last running factor into eax round ; round it off mov edx,[ebp+14h] ; move inWidth to edx register multiply eax,edx ; eax=inWidth*runningFactor mov edx,size RGB888 ; move sizeof(RGB888) to edx register multiply eax,edx ; eax=(inWidth*runningFactor)*sizeof(RGB888) mov dl,byte ptr[esi+eax] ; copy blue into dl mov byte ptr[edi],dl ; copy blue into target mov dl,byte ptr[esi+eax+1] ; copy green into dl mov byte ptr[edi+1],dl ; copy green into target mov dl,byte ptr[esi+eax+2] ; copy red into dl mov byte ptr[edi+2],dl ; copy red into target mov eax,sampleFactor ; move sampleFactor into eax register sub runningFactor,eax ; subtract from running factor dec ecx ; decrement counter sub edi,sOutColIterator ; advance backwards along lpOutArray jmp @@loopControl ; continue processing @@errorExit: ; error exit return sync address xor ax,ax ; clear ax register on error jmp @@endProcedure ; jump to end procedure @@exit: ; exit sync address mov ax,01h ; set ax register on success @@endProcedure: ; end procedure sync address pop ebx ; restore ebx register pop edi ; restore destination index register pop esi ; restore source index register add esp,LocalLength ; remove locals off stack pop ebp ; restore previous stack frame retn ; return near to caller _resampleClipCol endp _setAt proc near ; int setAt(ImageInfo *pImageInfo,DWORD row,DWORD col) push ebp ; save previous stack frame mov ebp,esp ; create new frame mov eax,(ImageInfo ptr [ebp+10h]).ImageInfo@@mSrcWidth pop ebp ; restore previous stack frame retn ; return near to caller _setAt endp public _resampleClipRow public _resampleClipCol public _setAt END