浏览代码

teraz wyświetlanie już działa, choć nie mam pojęcia, dlaczego ;]

mateuszb 18 年之前
父节点
当前提交
b85cd7c759
共有 3 个文件被更改,包括 12 次插入11 次删除
  1. 1 1
      CMT.cpp
  2. 10 9
      SDL_Extensions.cpp
  3. 1 1
      SDL_Extensions.h

+ 1 - 1
CMT.cpp

@@ -231,7 +231,7 @@ int _tmain(int argc, _TCHAR* argv[])
 		//SDL_Surface * ss = ac->defs[0]->ourImages[0].bitmap;
 		//SDL_BlitSurface(ss, NULL, ekran, NULL);
 
-		SDL_Delay(3000);
+		SDL_Delay(5000);
 			SDL_Quit();
 		return 0;
 	}

+ 10 - 9
SDL_Extensions.cpp

@@ -1,9 +1,9 @@
 #include "stdafx.h"
 #include "SDL_Extensions.h"
 
-void CSDL_Ext::SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B)
+void CSDL_Ext::SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC)
 {
-     Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel;
+     Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel-myC;
      if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
      {
           p[0] = R;
@@ -34,11 +34,11 @@ SDL_Surface * CSDL_Ext::rotate01(SDL_Surface * toRot)
 				Uint8 *p = (Uint8 *)toRot->pixels + j * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel;
 				if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 				{
-					SDL_PutPixel(ret, i, j, p[0], p[1], p[2]);
+					CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2], 2);
 				}
 				else
 				{
-					SDL_PutPixel(ret, i, j, p[2], p[1], p[0]);
+					CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0], 2);
 				}
 			}
 		}
@@ -55,14 +55,15 @@ SDL_Surface * CSDL_Ext::hFlip(SDL_Surface * toRot)
 		for(int j=0; j<ret->h; ++j)
 		{
 			{
-				Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j -1) * toRot->pitch + i * toRot->format->BytesPerPixel;
+				Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j -1) * toRot->pitch + i * toRot->format->BytesPerPixel-2;
+				int k=2;
 				if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 				{
-					SDL_PutPixel(ret, i, j, p[0], p[1], p[2]);
+					CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2], k);
 				}
 				else
 				{
-					SDL_PutPixel(ret, i, j, p[2], p[1], p[0]);
+					CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0], k);
 				}
 			}
 		}
@@ -114,11 +115,11 @@ SDL_Surface * CSDL_Ext::rotate03(SDL_Surface * toRot)
 				Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j - 1) * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel;
 				if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
 				{
-					SDL_PutPixel(ret, i, j, p[0], p[1], p[2]);
+					SDL_PutPixel(ret, i, j, p[0], p[1], p[2], 2);
 				}
 				else
 				{
-					SDL_PutPixel(ret, i, j, p[2], p[1], p[0]);
+					SDL_PutPixel(ret, i, j, p[2], p[1], p[0], 2);
 				}
 			}
 		}

+ 1 - 1
SDL_Extensions.h

@@ -5,7 +5,7 @@
 class CSDL_Ext
 {
 public:
-	static void SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B);
+	static void SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC=0); //myC influences the start of reading pixels
 	static SDL_Surface * rotate01(SDL_Surface * toRot);
 	static SDL_Surface * hFlip(SDL_Surface * toRot); //horizontal flip
 	static SDL_Surface * rotate02(SDL_Surface * toRot);