86 if SDL_MustLock(Image) then |
86 if SDL_MustLock(Image) then |
87 SDLTry(SDL_LockSurface(Image) >= 0, true); |
87 SDLTry(SDL_LockSurface(Image) >= 0, true); |
88 |
88 |
89 bpp:= Image.format.BytesPerPixel; |
89 bpp:= Image.format.BytesPerPixel; |
90 WriteToConsole('('+inttostr(bpp)+') '); |
90 WriteToConsole('('+inttostr(bpp)+') '); |
91 p:= LongWord(Image.pixels); |
91 p:= Image.pixels; |
92 case bpp of |
92 case bpp of |
93 1: OutError('We don''t work with 8 bit surfaces', true); |
93 1: OutError('We don''t work with 8 bit surfaces', true); |
94 2: for y:= 0 to Pred(Image.h) do |
94 2: for y:= 0 to Pred(Image.h) do |
95 begin |
95 begin |
96 i:= Longword(@Land[cpY + y, cpX]); |
|
97 for x:= 0 to Pred(Image.w) do |
96 for x:= 0 to Pred(Image.w) do |
98 if PWord(p + x * 2)^ <> 0 then PLongWord(i + x * 4)^:= COLOR_LAND; |
97 if PWord(@p[x * 2])^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND; |
99 inc(p, Image.pitch); |
98 p:= @p[Image.pitch]; |
100 end; |
99 end; |
101 3: for y:= 0 to Pred(Image.h) do |
100 3: for y:= 0 to Pred(Image.h) do |
102 begin |
101 begin |
103 i:= Longword(@Land[cpY + y, cpX]); |
|
104 for x:= 0 to Pred(Image.w) do |
102 for x:= 0 to Pred(Image.w) do |
105 if (PByte(p + x * 3 + 0)^ <> 0) |
103 if (p[x * 3 + 0] <> 0) |
106 or (PByte(p + x * 3 + 1)^ <> 0) |
104 or (p[x * 3 + 1] <> 0) |
107 or (PByte(p + x * 3 + 2)^ <> 0) then PLongWord(i + x * 4)^:= COLOR_LAND; |
105 or (p[x * 3 + 2] <> 0) then Land[cpY + y, cpX + x]:= COLOR_LAND; |
108 inc(p, Image.pitch); |
106 p:= @p[Image.pitch]; |
109 end; |
107 end; |
110 4: for y:= 0 to Pred(Image.h) do |
108 4: for y:= 0 to Pred(Image.h) do |
111 begin |
109 begin |
112 i:= Longword(@Land[cpY + y, cpX]); |
|
113 for x:= 0 to Pred(Image.w) do |
110 for x:= 0 to Pred(Image.w) do |
114 if PLongword(p + x * 4)^ <> 0 then PLongWord(i + x * 4)^:= COLOR_LAND; |
111 if PLongword(@p[x * 4])^ <> 0 then Land[cpY + y, cpX + x]:= COLOR_LAND; |
115 inc(p, Image.pitch); |
112 p:= @p[Image.pitch]; |
116 end; |
113 end; |
117 end; |
114 end; |
118 if SDL_MustLock(Image) then |
115 if SDL_MustLock(Image) then |
119 SDL_UnlockSurface(Image); |
116 SDL_UnlockSurface(Image); |
120 WriteLnToConsole(msgOK) |
117 WriteLnToConsole(msgOK) |