Cette routine effectue uniquement un etirement (agrandissement d'image)
[PRE]
#define PIXEL_IN_BYTE 8
#define BIT_OF_FIRST_PIXEL 0x80
void FN_Zoom(void)
{
short a, b, c, d, e, f, w, h, i, j, m, n, x, y, offset_left;
// x,y Zoom
a = ArgN[0] + Mode.OfstX;
b = ArgN[1] + Mode.OfstY;
if( !FindVarName(ArgS[0].str) ) return;
if( VatType!=PIC_TAG ) ERROR_SUB(err_nam);
// With, Height de l'image
e = *(short*)( FilePtr + 4 );
f = *(short*)( FilePtr + 2 );
//Controle etirement et mode
if( ArgN[2]<e || ArgN[3]<f || ArgN[4]<0 || ArgN[4]>2 || ArgN[5]<0 || ArgN[5]>3 ) ERROR_SUB(err_rng);
unsigned char *deb = (unsigned char *)FilePtr + 6;
// With, Height Zoom
w = ArgN[2];
h = ArgN[3];
// Xmax, Ymax
c = a + w;
d = b + h;
//Effacement de la zone de destination
if( ArgN[5] ) ScrRectFill ( &(SCR_RECT){{a, b, c, d}}, &Mode.clip ,ArgN[5] - 1 );
//Nombre de bytes(octets) par ligne
m = e / PIXEL_IN_BYTE + ( ( e % PIXEL_IN_BYTE )!=0 );
// Definition du Mode a appliquer aux pixels
SetCurAttr( ArgN[4] );
// Parcour des Pixel
for( i = 0; i<w; i++ ) {
// Rechercher abcisse Pixel correspondant dans l'image
x = ( i * e ) / w;
offset_left = x / PIXEL_IN_BYTE;
// Calcul du decallage
n = x % PIXEL_IN_BYTE;
// Parcour des Pixel
for( j = 0; j<h; j++ ) {
// Rechercher ordonnee Pixel correspondant dans l'image
y = ( j * f ) / h;
// Calcul du decallage
// Test etat Bit representant (x,y) dans l'image d'origine et affichage destination
if( (*(deb + y * m + offset_left)<<n ) & BIT_OF_FIRST_PIXEL ) DrawClipPix( a + i, b + j );
}
}
if( ArgS[1].str ) {
if( IsWindow( a, b, c, d ) ) SavePic(ArgS[1].str, a, b, c, d );
else ERROR_SET(err_rng);
}
}
[/PRE]
Extrait code source de ExtLiB