axiosengine 

axiosengine Commit Details


Date:2012-05-18 21:35:58 (12 years 4 months ago)
Author:Natalie Adams
Branch:master
Commit:2ffb70d9fc9b143bc9af4ec87607e732571c3431
Parents: fa897881c3cd92d238e259ee0db3b70955a943fe
Message:Changing location of GetTexture to extensions

Changes:

File differences

axios/Axios_WP7.csproj
166166
167167
168168
169
169170
170171
171172
<Compile Include="Engine\Data\AxiosDataTable.cs" />
<Compile Include="Engine\DrawableAxiosGameObject.cs" />
<Compile Include="Engine\DrawableBreakableAxiosGameObject.cs" />
<Compile Include="Engine\Extensions\Bitmap.cs" />
<Compile Include="Engine\Extensions\Contact.cs" />
<Compile Include="Engine\Extensions\String.cs" />
<Compile Include="Engine\Extensions\Texture2D.cs" />
axios/Axios_Windows.csproj
209209
210210
211211
212
212213
213214
214215
<Compile Include="Engine\Data\DataEvents.cs" />
<Compile Include="Engine\DrawableAxiosGameObject.cs" />
<Compile Include="Engine\DrawableBreakableAxiosGameObject.cs" />
<Compile Include="Engine\Extensions\Bitmap.cs" />
<Compile Include="Engine\Extensions\Contact.cs" />
<Compile Include="Engine\Extensions\String.cs" />
<Compile Include="Engine\Extensions\Texture2D.cs" />
axios/Axios_Xbox_360.csproj
159159
160160
161161
162
162163
163164
164165
<Compile Include="Engine\Data\DataEvents.cs" />
<Compile Include="Engine\DrawableAxiosGameObject.cs" />
<Compile Include="Engine\DrawableBreakableAxiosGameObject.cs" />
<Compile Include="Engine\Extensions\Bitmap.cs" />
<Compile Include="Engine\Extensions\Contact.cs" />
<Compile Include="Engine\Extensions\String.cs" />
<Compile Include="Engine\Extensions\Texture2D.cs" />
axios/Axios_settings.cs
8686
8787
8888
89
8990
9091
9192
* 1.0.1.6 - 5/18/2012
* - Adding cut extension - [Author: BJD]
* - Adding support for custom handling of Gleed2D items
* - Changing location of GetTexture to extensions
*
*/
#endregion
axios/Engine/AxiosGameScreen.cs
415415
416416
417417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441418
442
443
444
445
446
447
448
449
450
451
452419
453420
return true;
}
#if WINDOWS
// System.Drawing is NOT avaiable on WP7 or Xbox
/*
* http://stackoverflow.com/a/7394185/195722
*
*
*
*/
public Texture2D GetTexture(System.Drawing.Bitmap bitmap)
{
BlendState oldstate = ScreenManager.GraphicsDevice.BlendState;
ScreenManager.GraphicsDevice.BlendState = BlendState.AlphaBlend;
Texture2D tex = new Texture2D(this.ScreenManager.GraphicsDevice, bitmap.Width, bitmap.Height, true, SurfaceFormat.Color);
System.Drawing.Imaging.BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat);
int bufferSize = data.Height * data.Stride;
//create data buffer
byte[] bytes = new byte[bufferSize];
// copy bitmap data into buffer
System.Runtime.InteropServices.Marshal.Copy(data.Scan0, bytes, 0, bytes.Length);
// copy our buffer to the texture
tex.SetData(bytes);
// unlock the bitmap data
bitmap.UnlockBits(data);
this.ScreenManager.GraphicsDevice.BlendState = oldstate;
return tex;
}
#endif
}
}
axios/Engine/Extensions/Bitmap.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using GameStateManagement;
namespace Axios.Engine.Extensions
{
public static class Bitmap_extension
{
#if WINDOWS
// System.Drawing is NOT avaiable on WP7 or Xbox
/*
* http://stackoverflow.com/a/7394185/195722
*
*
*
*/
public static Texture2D GetTexture(this System.Drawing.Bitmap bitmap, GameScreen gameScreen)
{
BlendState oldstate = gameScreen.ScreenManager.GraphicsDevice.BlendState;
gameScreen.ScreenManager.GraphicsDevice.BlendState = BlendState.AlphaBlend;
Texture2D tex = new Texture2D(gameScreen.ScreenManager.GraphicsDevice, bitmap.Width, bitmap.Height, true, SurfaceFormat.Color);
System.Drawing.Imaging.BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat);
int bufferSize = data.Height * data.Stride;
//create data buffer
byte[] bytes = new byte[bufferSize];
// copy bitmap data into buffer
System.Runtime.InteropServices.Marshal.Copy(data.Scan0, bytes, 0, bytes.Length);
// copy our buffer to the texture
tex.SetData(bytes);
// unlock the bitmap data
bitmap.UnlockBits(data);
gameScreen.ScreenManager.GraphicsDevice.BlendState = oldstate;
return tex;
}
#endif
}
}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.22402s using 14 queries.