Anonymous avatar Anonymous committed 138b9cb

rotozoom works on 8bit

Comments (0)

Files changed (2)

src/SDL_rotozoom/README

+This is the README file for SDL_Rotozoom
+note that this source has had some changes from version 1.4 of SDL_rotozoom
+
+The rotozoom function has been changed to always return a 32bit surface
+if smoothing has been requested.
+
+
+
+The following is the original README file...
 
 
 Rotozoom/Zoom function for SDL

src/SDL_rotozoom/SDL_rotozoom.c

 
 #include <stdlib.h>
 #include <string.h>
+#include "SDL_rotozoom.h"
 
-#include "SDL_rotozoom.h"
+#ifndef max
+#define max(A,B) (((A)>(B)?(A):(B))
+#endif
 
 /* 
  
  double radangle, sanglezoom, canglezoom, sanglezoominv, canglezoominv;
  int dstwidthhalf, dstwidth, dstheighthalf, dstheight;
  double x,y,cx,cy,sx,sy;
- int is32bit;
- int i,src_converted;
+ int src_converted;
 
  /* Sanity check */
  if (src==NULL) return(NULL);
 
  /* Determine if source surface is 32bit or 8bit */
- is32bit=(src->format->BitsPerPixel==32);
- if ( (is32bit) || (src->format->BitsPerPixel==8)) {
+ if ( src->format->BitsPerPixel==32 ) {
   /* Use source surface 'as is' */
   rz_src=src;
   src_converted=0;
   rz_src = SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
   SDL_BlitSurface(src,NULL,rz_src,NULL);
   src_converted=1;
-  is32bit=1;
  }
         
  /* Sanity check zoom factor */
  
   /* Alloc space to completely contain the rotated surface */
   rz_dst=NULL;
-  if (is32bit) {
-   /* Target surface is 32bit with source RGBA/ABGR ordering */
-   rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight, 32, rz_src->format->Rmask, rz_src->format->Gmask, rz_src->format->Bmask, rz_src->format->Amask);
-  } else {
-   /* Target surface is 8bit */
-   rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight, 8, 0, 0, 0, 0);
-  }
+  rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight, 32, rz_src->format->Rmask, rz_src->format->Gmask, rz_src->format->Bmask, rz_src->format->Amask);
 
   /* Lock source surface */
   SDL_LockSurface(rz_src);
+
   /* Check which kind of surface we have */
-  if (is32bit) {
-   /* Call the 32bit transformation routine to do the rotation (using alpha) */
-   transformSurfaceRGBA(rz_src,rz_dst,dstwidthhalf,dstheighthalf,
-  		      (int)(sanglezoominv),
- 		      (int)(canglezoominv),
- 		      smooth);
-   /* Turn on source-alpha support */
-   SDL_SetAlpha(rz_dst, SDL_SRCALPHA , 255);
-  } else {
-   /* Copy palette and colorkey info */
-   for (i=0; i<rz_src->format->palette->ncolors; i++) {
-    rz_dst->format->palette->colors[i]=rz_src->format->palette->colors[i];
-   }
-   rz_dst->format->palette->ncolors=rz_src->format->palette->ncolors;
-   /* Call the 8bit transformation routine to do the rotation */
-   transformSurfaceY(rz_src,rz_dst,dstwidthhalf,dstheighthalf,
-  		      (int)(sanglezoominv),
- 		      (int)(canglezoominv));
-   SDL_SetColorKey(rz_dst, SDL_SRCCOLORKEY | SDL_RLEACCEL, rz_src->format->colorkey);
-  }			
+  /* Call the 32bit transformation routine to do the rotation (using alpha) */
+  transformSurfaceRGBA(rz_src,rz_dst,dstwidthhalf,dstheighthalf,
+  	      (int)(sanglezoominv),
+ 	      (int)(canglezoominv),
+ 	      smooth);
+
+  /* Turn on source-alpha support */
+  SDL_SetAlpha(rz_dst, SDL_SRCALPHA , 255);
+
   /* Unlock source surface */
   SDL_UnlockSurface(rz_src);
 
 
   /* Alloc space to completely contain the zoomed surface */
   rz_dst=NULL;
-  if (is32bit) {
-   /* Target surface is 32bit with source RGBA/ABGR ordering */
-   rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight, 32, rz_src->format->Rmask, rz_src->format->Gmask, rz_src->format->Bmask, rz_src->format->Amask);
-  } else {
-   /* Target surface is 8bit */
-   rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight, 8, 0, 0, 0, 0);
-  }
+  rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight, 32, rz_src->format->Rmask, rz_src->format->Gmask, rz_src->format->Bmask, rz_src->format->Amask);
 
   /* Lock source surface */
   SDL_LockSurface(rz_src);
   /* Check which kind of surface we have */
-  if (is32bit) {
-   /* Call the 32bit transformation routine to do the zooming (using alpha) */
-   zoomSurfaceRGBA(rz_src,rz_dst,smooth);
-   /* Turn on source-alpha support */
-   SDL_SetAlpha(rz_dst, SDL_SRCALPHA , 255);
-  } else {
-   /* Copy palette and colorkey info */
-   for (i=0; i<rz_src->format->palette->ncolors; i++) {
-    rz_dst->format->palette->colors[i]=rz_src->format->palette->colors[i];
-   }
-   rz_dst->format->palette->ncolors=rz_src->format->palette->ncolors;
-   /* Call the 8bit transformation routine to do the zooming */
-   zoomSurfaceY(rz_src,rz_dst);
-   SDL_SetColorKey(rz_dst, SDL_SRCCOLORKEY | SDL_RLEACCEL, rz_src->format->colorkey);
-  }			
+  /* Call the 32bit transformation routine to do the zooming (using alpha) */
+  zoomSurfaceRGBA(rz_src,rz_dst,smooth);
+  /* Turn on source-alpha support */
+  SDL_SetAlpha(rz_dst, SDL_SRCALPHA , 255);
+
   /* Unlock source surface */
   SDL_UnlockSurface(rz_src);
  }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.