コード例 #1
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Loads an image from a storage into a texture.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <param name="shouldDispose">Whether the storage should be disposed when loading is finished.</param>
 /// <param name="type">The type of the image.</param>
 /// <param name="renderer">The renderer.</param>
 /// <param name="colorKey">The color key for the image.</param>
 /// <returns>The image.</returns>
 public static Texture Load(RWOps rwops, bool shouldDispose, string type, Renderer renderer, Color?colorKey = default)
 {
     using var loadedSurface = Load(rwops, shouldDispose, type);
     if (colorKey != null)
     {
         loadedSurface.ColorKey = loadedSurface.PixelFormat.Map(colorKey.Value.Red, colorKey.Value.Green, colorKey.Value.Blue, colorKey.Value.Alpha);
     }
     return(renderer.CreateTexture(loadedSurface));
 }
コード例 #2
0
ファイル: Tileset.cs プロジェクト: panopticoncentral/libcgs
 internal Tileset(Renderer renderer, Size tileSize, Size margin, Size size, string type, byte[] resource, Color?colorKey)
 {
     TileSize  = tileSize;
     Margin    = margin;
     Size      = size;
     _colorKey = colorKey;
     _type     = type;
     Texture   = Image.Load(RWOps.CreateReadOnly(resource), true, _type, renderer, _colorKey);
 }
コード例 #3
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an PNM image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsPnm(RWOps rwops) =>
 Native.IMG_isPNM(rwops.Native);
コード例 #4
0
ファイル: Image.cs プロジェクト: harry-cpp/sdl-sharp
 /// <summary>
 /// Whether the storage is an PNG image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsPng(RWOps rwops) =>
 Native.IMG_isPNG(rwops.Pointer);
コード例 #5
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an PCX image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsPcx(RWOps rwops) =>
 Native.IMG_isPCX(rwops.Native);
コード例 #6
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Load a Webp image from a storage.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns>The image.</returns>
 public static Surface LoadWebp(RWOps rwops) =>
 Surface.PointerToInstanceNotNull(Native.IMG_LoadWEBP_RW(rwops.Native));
コード例 #7
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Saves a surface as a JPG image.
 /// </summary>
 /// <param name="surface">The surface.</param>
 /// <param name="rwops">The storage.</param>
 /// <param name="shouldDispose">Whether the storage should be disposed when loading is finished.</param>
 /// <param name="quality">The quality to save as.</param>
 public static void SaveJpg(Surface surface, RWOps rwops, bool shouldDispose, int quality) =>
 Native.CheckError(Native.IMG_SaveJPG_RW(surface.Native, rwops.Native, shouldDispose, quality));
コード例 #8
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an XCF image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsXcf(RWOps rwops) =>
 Native.IMG_isXCF(rwops.Native);
コード例 #9
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an XV image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsXv(RWOps rwops) =>
 Native.IMG_isXV(rwops.Native);
コード例 #10
0
ファイル: Gesture.cs プロジェクト: harry-cpp/sdl-sharp
 /// <summary>
 /// Save all the dollar templates.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 public static void SaveAllDollarTemplates(RWOps rwops) =>
 Native.CheckError(Native.SDL_SaveAllDollarTemplates(rwops.Pointer));
コード例 #11
0
ファイル: Gesture.cs プロジェクト: harry-cpp/sdl-sharp
 /// <summary>
 /// Save a dollar template.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 public void SaveDollarTemplate(RWOps rwops) =>
 Native.CheckError(Native.SDL_SaveDollarTemplate(Index, rwops.Pointer));
コード例 #12
0
ファイル: GameController.cs プロジェクト: Ciastex/sdl-sharp
 /// <summary>
 /// Adds game controller mappings from the data source.
 /// </summary>
 /// <param name="rwops">The data source.</param>
 /// <param name="shouldDispose">Whether the data source should be disposed after use.</param>
 /// <returns>The number of mappings added.</returns>
 public static int AddMappings(RWOps rwops, bool shouldDispose) =>
 Native.CheckError(Native.SDL_GameControllerAddMappingsFromRW(rwops.Pointer, shouldDispose));
コード例 #13
0
ファイル: Gesture.cs プロジェクト: harry-cpp/sdl-sharp
 /// <summary>
 /// Loads a dollar template.
 /// </summary>
 /// <param name="device">The touch device.</param>
 /// <param name="rwops">The storage.</param>
 public static void LoadDollarTemplates(TouchDevice device, RWOps rwops) =>
 Native.CheckError(Native.SDL_LoadDollarTemplates(device.Index, rwops.Pointer));
コード例 #14
0
ファイル: Image.cs プロジェクト: harry-cpp/sdl-sharp
 /// <summary>
 /// Loads an image from a storage.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <param name="shouldDispose">Whether the storage should be disposed when loading is finished.</param>
 /// <param name="type">The type of the image.</param>
 /// <returns>The image.</returns>
 public static Surface Load(RWOps rwops, bool shouldDispose, string type) =>
 Surface.PointerToInstanceNotNull(Native.IMG_LoadTyped_RW(rwops.Pointer, shouldDispose, type));
コード例 #15
0
ファイル: Image.cs プロジェクト: harry-cpp/sdl-sharp
 /// <summary>
 /// Load a Xv image from a storage.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns>The image.</returns>
 public static Surface LoadXv(RWOps rwops) =>
 Surface.PointerToInstanceNotNull(Native.IMG_LoadXV_RW(rwops.Pointer));
コード例 #16
0
ファイル: Image.cs プロジェクト: harry-cpp/sdl-sharp
 /// <summary>
 /// Whether the storage is an XV image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsXv(RWOps rwops) =>
 Native.IMG_isXV(rwops.Pointer);
コード例 #17
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an SVG image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsSvg(RWOps rwops) =>
 Native.IMG_isSVG(rwops.Native);
コード例 #18
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an ICO image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsIco(RWOps rwops) =>
 Native.IMG_isICO(rwops.Native);
コード例 #19
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an TIFF image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsTif(RWOps rwops) =>
 Native.IMG_isTIF(rwops.Native);
コード例 #20
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an CUR image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsCur(RWOps rwops) =>
 Native.IMG_isCUR(rwops.Native);
コード例 #21
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an XPM image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsXpm(RWOps rwops) =>
 Native.IMG_isXPM(rwops.Native);
コード例 #22
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an BMP image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsBmp(RWOps rwops) =>
 Native.IMG_isBMP(rwops.Native);
コード例 #23
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an WEBP image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsWebp(RWOps rwops) =>
 Native.IMG_isWEBP(rwops.Native);
コード例 #24
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Loads an image from a storage.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <param name="shouldDispose">Whether the storage should be disposed when loading is finished.</param>
 /// <returns>The image.</returns>
 public static Surface Load(RWOps rwops, bool shouldDispose) =>
 Surface.PointerToInstanceNotNull(Native.IMG_Load_RW(rwops.Native, shouldDispose));
コード例 #25
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Saves a surface as a PNG image.
 /// </summary>
 /// <param name="surface">The surface.</param>
 /// <param name="rwops">The storage.</param>
 /// <param name="shouldDispose">Whether the storage should be disposed when loading is finished.</param>
 public static void SavePng(Surface surface, RWOps rwops, bool shouldDispose) =>
 Native.CheckError(Native.IMG_SavePNG_RW(surface.Native, rwops.Native, shouldDispose));
コード例 #26
0
ファイル: Image.cs プロジェクト: harry-cpp/sdl-sharp
 /// <summary>
 /// Loads an image as a texture from a storage.
 /// </summary>
 /// <param name="renderer">The renderer.</param>
 /// <param name="rwops">The storage.</param>
 /// <param name="shouldDispose">Whether the storage should be disposed when loading is finished.</param>
 /// <returns>The texture.</returns>
 public static Texture LoadTexture(Renderer renderer, RWOps rwops, bool shouldDispose) =>
 Texture.PointerToInstanceNotNull(Native.IMG_LoadTexture_RW(renderer.Pointer, rwops.Pointer, shouldDispose));
コード例 #27
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an JPG image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsJpg(RWOps rwops) =>
 Native.IMG_isJPG(rwops.Native);
コード例 #28
0
ファイル: Image.cs プロジェクト: harry-cpp/sdl-sharp
 /// <summary>
 /// Whether the storage is an GIF image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsGif(RWOps rwops) =>
 Native.IMG_isGIF(rwops.Pointer);
コード例 #29
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Loads an image as a texture from a storage.
 /// </summary>
 /// <param name="renderer">The renderer.</param>
 /// <param name="rwops">The storage.</param>
 /// <param name="shouldDispose">Whether the storage should be disposed when loading is finished.</param>
 /// <param name="type">The type of the image.</param>
 /// <returns>The texture.</returns>
 public static Texture LoadTexture(Renderer renderer, RWOps rwops, bool shouldDispose, string type) =>
 Texture.PointerToInstanceNotNull(Native.IMG_LoadTextureTyped_RW(renderer.Native, rwops.Native, shouldDispose, type));
コード例 #30
0
ファイル: Image.cs プロジェクト: panopticoncentral/sdl-sharp
 /// <summary>
 /// Whether the storage is an LBM image.
 /// </summary>
 /// <param name="rwops">The storage.</param>
 /// <returns><c>true</c> if it is, <c>false</c> otherwise.</returns>
 public static bool IsLbm(RWOps rwops) =>
 Native.IMG_isLBM(rwops.Native);