1

Hello,
Je voulais savoir si y'a une fonction qui permettre de strecher une image.
Par exemple j'ai une image de 320*240 sur mon tileset.h et je voudrais ne le faire apparaitre qu'en 160*120 sur l'ecran de la gp. ( doncçaimplique de zapper une pixel sur 2 ) J'ai eu l'idée de creer une fonction qui recup chaque pixel puis qui en zappe une sur deux. mais bon.. y'a ptet une fonction que recalcule pour avoir une image correcte.
J'ai essayé de voir quelques fonctions dans la source de kof.. mais c assez obscure pour moi vu que le code est hyper optimisé.

Voila mici ^^

2

voila alors j'ai cerné un bout de code : COLOR getpixel(BITMAP* b,int x,int y) {      return b->buf[x*b->h+y]; } void putpixel(BITMAP* b,int x,int y,COLOR c) {      b->buf[x*b->h+y] = c; } void drawing_mode(int mode,BITMAP* b,int x,int y) {      dm_mode = mode;      dm_bitmap = b;      dm_x = x;      dm_y = y; } void rect(BITMAP* b,int x0,int y0,int x1,int y1,COLOR c) {      int i,j,k,w=x1-x0,h=y1-y0;      /* horizontal */      j = (x0+0)*b->h+y0;      for (i=0;i<w;i++)      {           b->buf[j] = c;           b->buf[j+h] = c;           j+=b->h;      }      /* vertical */      j = (x0+0)*b->h+y0+1;      k = (x1+0)*b->h+y0+1;      for (i=1;i<h;i++)           b->buf[j++] = b->buf[k++] = c; }
mais impossible de la faire marcher.

3

ouais en fait c du pixel par pixel et ça genere un bmp à la volée n dirait...
rtb7 si tu passes par la.. j'aimerais bien connaitre juste ta methode smile

4

Voila la version c de ma routine de zoom, j'espere que le code est compréhensible...
static inline void ZoomBlit(int numsurface, int dx, int dy, int width, int height, unsigned char *src, int zoomf) {   register i, j;   int xmin = 0;   int ymin = 0;   int x2 = (dx << 16) / zoomf;   int y2 = (dy << 16) / zoomf;   int w2 = ( (dx + width) << 16) / zoomf - x2;   int h2 = ( (dy + height) << 16) / zoomf - y2; //  int w2 = ( (width << 16) + zoomf - 1) / zoomf; //  int h2 = ( (height << 16) + zoomf - 1) / zoomf;   int xmax = w2 - 1;   int ymax = h2 - 1;   int height2 = ( (height + 3) >> 2) * 4;   int decaly = screen_height - h2 - y2;   if(x2 < 0) xmin = -x2;   if( (x2 + w2) > play_width) xmax = play_width - x2 - 1;   if(y2 < 0) ymax = h2 + y2 - 1;   if( (y2 + h2) > screen_height) ymin = y2 + h2 - screen_height;   if(xmin > xmax) return;   if(ymin > ymax) return;   unsigned char *src4;   unsigned char *dst4 = gpDraw[numsurface].ptbuffer + (x2 + xmax) * screen_height + decaly + ymax;         for(i = xmin; i < xmax; i++) {     src4 = src + ( (i * zoomf) >> 16) * height2;     for(j = ymin; j < ymax; j++) {       *dst4++ = *(src4 + ( (j * zoomf) >> 16) );     }     dst4 += (screen_height - ymax + ymin);   } }

ps: zoomf = 65536 => zoom = 1
zoomf < 65536 => zoom avant
zoomf > 65536 => zoom arriere

5

le dernier source est correct, sauf que moi je calcule 1 seule fois les zooms en y pour eviter de faire trop de *

for(j = ymin; j < ymax; j++) {
*dst4++ = *(src4 + ( (j * zoomf) >> 16) );
}

deviendrai :

for(j = 0; j < ymax-ymin; j++) {
*dst4++ = *(src4 + zy[j]);
}

ou les zy aurait été calculé avant la boucle sur les x :

for(j = ymin; j < ymax; j++)
zy[j-ymin] = ( (j * zoomf) >> 16) ;


comme ça, c + rapide

Thor

6

excellent !!!! merci smile