1 ;-----------------------------------------------------------
\r
3 ; MXPI.ASM - Stretch image
\r
4 ; Copyright (c) 1994 by Alessandro Scotti
\r
6 ;-----------------------------------------------------------
\r
11 PUBLIC mxStretchImage
\r
13 EXTRN subClipBox : NEAR
\r
15 MX_TEXT SEGMENT USE16 PARA PUBLIC 'CODE'
\r
16 ASSUME cs:MX_TEXT, ds:NOTHING, es:NOTHING
\r
18 EXTRN mx_VideoSegment : WORD
\r
19 EXTRN mx_BytesPerLine : WORD
\r
21 mxTable LABEL WORD ; Raster ops
\r
29 ;-----------------------------------------------------------
\r
31 ; Stretches and copies a "raw" image from memory to screen.
\r
34 ; Image = pointer to image
\r
35 ; X, Y = coordinates of destination
\r
36 ; Width = width of image in pixels
\r
37 ; Height = height of image in pixels
\r
38 ; NewWidth = new width of image in pixels
\r
39 ; NewHeight = new height of image in pixels
\r
40 ; Op = raster op (OP_xxx)
\r
44 mxStretchImage PROC FAR
\r
52 Image:DWORD = ARG_SIZE
\r
53 LOCAL PixelOffset:WORD, \
\r
54 MoveFunction:WORD, \
\r
60 WritePlane:BYTE = AUTO_SIZE
\r
63 .push ds, si, es, di
\r
65 ; Get width stretch factor
\r
69 movzx ebx, [NewWidth]
\r
72 mov [WidthStep], eax
\r
74 xor dx, dx ; Width stretch factor
\r
78 mov WORD PTR WidthStep[2], ax
\r
81 mov WORD PTR WidthStep[0], ax
\r
83 ; Get height stretch factor
\r
87 movzx ebx, [NewHeight]
\r
90 mov [HeightStep], eax
\r
96 mov WORD PTR HeightStep[2], ax
\r
99 mov WORD PTR HeightStep[0], ax
\r
106 mov dx, [NewHeight]
\r
108 jc @@Exit ; Full clipped
\r
110 mov [NewHeight], dx
\r
114 ; Get pixel address
\r
115 mul [mx_BytesPerLine]
\r
120 mov [PixelOffset], di
\r
121 mov es, [mx_VideoSegment] ; ES:DI points to pixel
\r
123 mov [ReadPlane], bl ; Set read plane
\r
127 mov [WritePlane], al ; Set write plane
\r
129 ; Relocate image origin if previously clipped
\r
140 mul WORD PTR HeightStep[0]
\r
143 mul WORD PTR HeightStep[2]
\r
147 add WORD PTR [Image], ax
\r
155 add WORD PTR [Image], dx
\r
158 mul WORD PTR WidthStep[0]
\r
161 mul WORD PTR WidthStep[2]
\r
163 add WORD PTR [Image], ax
\r
166 mov ax, WORD PTR HeightStep[2]
\r
168 mov WORD PTR HeightStep[2], ax
\r
170 ; Install move function
\r
172 mov [OpInfo], bh ; Remember additional info if needed
\r
175 jbe @@SetMoveFunction
\r
179 mov ax, mxTable[bx]
\r
180 mov [MoveFunction], ax
\r
183 mov ds, WORD PTR Image[2]
\r
187 mov si, WORD PTR Image[0] ; Get pointer to image
\r
188 mov ah, [WritePlane]
\r
192 out dx, ax ; Select write plane
\r
193 mov ah, [ReadPlane]
\r
197 out dx, ax ; Select read plane
\r
198 mov cx, [NewHeight]
\r
199 mov di, [PixelOffset] ; ES:DI points to video memory
\r
200 mov ah, [OpInfo] ; Additional raster op info
\r
202 mov dx, [mx_BytesPerLine]
\r
203 call [MoveFunction] ; Draw column
\r
204 inc [ReadPlane] ; Next read plane
\r
205 rol [WritePlane], 1 ; Next write plane
\r
206 adc [PixelOffset], 0 ; Update video offset if needed
\r
207 mov dx, WORD PTR WidthStep[0]
\r
208 mov ax, WORD PTR WidthStep[2]
\r
210 adc WORD PTR Image[0], ax ; Next image column
\r
212 jnz @@Loop ; Repeat for all columns
\r
216 .pop ds, si, es, di
\r
219 ;-----------------------------------------------------------
\r
221 ; Move functions, on entry:
\r
222 ; AH = additional raster op info (e.g. transparent color)
\r
224 ; CX = pixel count,
\r
225 ; DX = mx_BytesPerLine.
\r
228 @@Loop: mov al, ds:[si]
\r
233 add si, WORD PTR HeightStep[2]
\r
234 add bx, WORD PTR HeightStep[0]
\r
242 @@Loop: mov al, ds:[si]
\r
247 add si, WORD PTR HeightStep[2]
\r
248 add bx, WORD PTR HeightStep[0]
\r
256 @@Loop: mov al, ds:[si]
\r
261 add si, WORD PTR HeightStep[2]
\r
262 add bx, WORD PTR HeightStep[0]
\r
270 @@Loop: mov al, ds:[si]
\r
275 add si, WORD PTR HeightStep[2]
\r
276 add bx, WORD PTR HeightStep[0]
\r
284 @@Loop: mov al, ds:[si]
\r
292 add si, WORD PTR HeightStep[2]
\r
293 add bx, WORD PTR HeightStep[0]
\r
301 @@Loop: mov al, ds:[si]
\r
306 add si, WORD PTR HeightStep[2]
\r
307 add bx, WORD PTR HeightStep[0]
\r
314 mxStretchImage ENDP
\r