public void Draw(IImageResource texture, Rectangle destinationRectangle, Rectangle? sourceRectangle, Color color) { if (texture != null) { spriteBatch.Draw(((XNAImageResource)texture).Texture, destinationRectangle, sourceRectangle, color); } }
public TextureSprite(IImageResource resource, Vector2 position, Vector2 size, Vector2 sourcePos, Vector2 sourceSize,SBColor tintColor, double opacity = 1.0) :base(resource, position, size, tintColor, opacity) { SourcePosition = sourcePos; SourceSize = sourceSize; }
private IEnumerable <OutputImage> GetAppIconSet(IImageResource resource, string basePath) { var contentsJson = Path.Combine(Build.ProjectDirectory, basePath, "Contents.json"); if (!imageResourcePaths.Any(x => x == contentsJson)) { imageResourcePaths.Add(contentsJson); } var iconset = JsonConvert.DeserializeObject <AppleIconSet>( File.ReadAllText(contentsJson)); var iconsetImages = new List <AppleIconSetImage>(); foreach (var image in iconset.Images) { // Require png file name if (string.IsNullOrEmpty(image.FileName) || Path.GetExtension(image.FileName) != ".png") { continue; } // Skip duplicate resources if (iconsetImages.Any(x => x.FileName == image.FileName)) { continue; } iconsetImages.Add(image); yield return(GetOutputImage(image, resource, basePath, resource.Name)); } }
private OutputImage GetOutputImage(AppleIconSetImage x, IImageResource resource, string basePath, string outputFileName) { var scale = int.Parse(x.Scale[0].ToString()); var size = x.Size.Split('x'); Log.LogMessage($"Found App Icon Set image {resource.SourceFile} -> {basePath}{Path.DirectorySeparatorChar}{x.FileName}"); var outputFile = Path.Combine(Build.IntermediateOutputPath, basePath, x.FileName); var outputLink = Path.Combine(basePath, x.FileName); var watermarkFilePath = GetWatermarkFilePath(resource); var width = (int)(double.Parse(size[0]) * scale); var height = (int)(double.Parse(size[1]) * scale); return(new OutputImage { InputFile = resource.SourceFile, OutputFile = outputFile, OutputLink = outputLink, Width = width, Height = height, RequiresBackgroundColor = outputFileName == "AppIcon", ShouldBeVisible = false, //WatermarkFilePath = watermarkFilePath, Watermark = resource.Watermark, BackgroundColor = resource.BackgroundColor, BuildAction = "ImageAsset" }); }
public void Draw(IImageResource texture, Rectangle rectangle, Color color) { if (texture != null) { spriteBatch.Draw(((XNAImageResource)texture).Texture, rectangle, color); } }
public Sprite(IImageResource resource, Vector2 position, Vector2 size, SBColor tintColor, double opacity = 1.0) { Resource = resource; Position = position; Size = size; TintColor = tintColor; Opacity = opacity; }
public static IImageResource Create(IImageResource src) { return(new ImageResource { Name = src.Name, Url = src.Url }); }
protected internal override IEnumerable<OutputImage> GetOutputImages(IImageResource config) { if (config.Ignore) { return Array.Empty<OutputImage>(); } #if DEBUG if (config.Name is null) { if (System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break(); else if(!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) System.Diagnostics.Debugger.Launch(); } #endif // Check for appiconset var assetsIconSetBasePath = Path.Combine( "Assets.xcassets", $"{config.Name}.appiconset"); var mediaRootIconSetBasePath = Path.Combine( "Media.xcassets", $"{config.Name}.appiconset"); var mediaIconSetBasePath = Path.Combine( "Resources", "Assets.xcassets", $"{config.Name}.appiconset"); if (Directory.Exists(Path.Combine(Build.ProjectDirectory, assetsIconSetBasePath))) { return GetAppIconSet(config, assetsIconSetBasePath); } else if (Directory.Exists(Path.Combine(Build.ProjectDirectory, mediaRootIconSetBasePath))) { return GetAppIconSet(config, mediaRootIconSetBasePath); } else if (Directory.Exists(Path.Combine(Build.ProjectDirectory, mediaIconSetBasePath))) { return GetAppIconSet(config, mediaIconSetBasePath); } else { Log.LogMessage($"Found image {config.SourceFile} -> Resources/{config.Name}.png"); // Generate App Resources return ResourceSizes.Select(x => new OutputImage { InputFile = config.SourceFile, OutputFile = Path.Combine(Build.IntermediateOutputPath, "Resources", $"{config.Name}{x.Key}.png"), OutputLink = Path.Combine("Resources", $"{config.Name}{x.Key}.png"), Scale = config.Scale * x.Value, ShouldBeVisible = true, Watermark = config.Watermark, BackgroundColor = config.BackgroundColor, BuildAction = "BundleResource" }); } }
public static string GetBase64URL(IImageResource res) { StringBuilder sb = new StringBuilder("data:"); sb.Append(res.ContentType); sb.Append(";base64,"); byte[] data = res.GetImageData(); sb.Append(Convert.ToBase64String(data, 0, data.Length, Base64FormattingOptions.None)); return sb.ToString(); }
protected string GetWatermarkFilePath(IImageResource resource) { var fileName = resource.Watermark?.SourceFile; if (string.IsNullOrEmpty(fileName)) { return(null); } return(ImageInputFiles.FirstOrDefault(x => Path.GetFileNameWithoutExtension(x) == fileName || Path.GetFileName(x) == fileName)); }
public ExtendedCSSResource(bool? compress, bool defaultCompress, IResource[] references, IImageResource[] imageIncludes, ICSSResource[] includes, ICSSResource[] builds, FileLocation location, bool hasContent) { _defaultCompress = defaultCompress; _hasContent = hasContent; _compress = compress; _builds = builds; _references = references; _includes = includes; _imageIncludes = imageIncludes; _location = location; _version = ChecksumHelper.GetCombinedChecksum(location.Version, _includes, _builds); }
//------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ public ITexture CreateTexture(IImageResource image) { ITexture ret = this._context.CreateTexture(); this._context.BindTexture(WebGLE.Texture_2D, ret); this._context.PixelStorei(WebGLE.UnpackFlipY, 1); this._context.TexImage2D(WebGLE.Texture_2D, 0, WebGLE.Rgba, WebGLE.Rgba, WebGLE.UnsignedByteT, image); this._context.TexParameteri(WebGLE.Texture_2D, WebGLE.TextureMagFilter, WebGLE.Nearest); this._context.TexParameteri(WebGLE.Texture_2D, WebGLE.TextureMinFilter, WebGLE.Nearest); this._context.BindTexture(WebGLE.Texture_2D, null); return ret; }
protected internal override IEnumerable <OutputImage> GetOutputImages(IImageResource config) { if (config.Ignore) { yield return(default);
protected internal abstract IEnumerable <OutputImage> GetOutputImages(IImageResource resource);
public static async Task Export(IReadOnlyList <IImageProvider> images, Rect?animatedArea) { // List of aligned images may contain Null items if the particular image couldn't be aligned List <IImageProvider> sanitizedImages = new List <IImageProvider>(); foreach (IImageProvider image in images) { if (image != null) { sanitizedImages.Add(image); } } IImageResource info = null; IAsyncImageResource asyncImageResource = sanitizedImages[0] as IAsyncImageResource; if (asyncImageResource == null) { info = sanitizedImages[0] as IImageResource; } int w = (int)info.ImageSize.Width; int h = (int)info.ImageSize.Height; IReadOnlyList <IImageProvider> gifRendererSources; if (animatedArea.HasValue) { // Ensure the animated area dimensions are smaller than the image dimensions double rectW = animatedArea.Value.Width; double rectH = animatedArea.Value.Height; if ((animatedArea.Value.Width + animatedArea.Value.Left) >= w) { rectW = w - animatedArea.Value.Left - 1; } if ((animatedArea.Value.Top + animatedArea.Value.Height) >= h) { rectH = h - animatedArea.Value.Top - 1; } Rect rect = new Rect(animatedArea.Value.Left, animatedArea.Value.Top, rectW, rectH); gifRendererSources = CreateFramedAnimation(sanitizedImages, rect, w, h); } else { gifRendererSources = sanitizedImages; } using (GifRenderer gifRenderer = new GifRenderer()) { gifRenderer.Duration = 100; gifRenderer.NumberOfAnimationLoops = 10000; gifRenderer.Sources = gifRendererSources; var buffer = await gifRenderer.RenderAsync(); var filename = "Sequence" + (await GetFileNameRunningNumber()) + ".gif"; var storageFile = await KnownFolders.SavedPictures.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting); using (var stream = await storageFile.OpenAsync(FileAccessMode.ReadWrite)) { await stream.WriteAsync(buffer); } } }
public BorderSprite(IImageResource resource, Vector2 position, Vector2 size, Thickness border, SBColor tintColor, double opacity = 1.0) : base(resource, position, size, tintColor, opacity) { Border = border; }
public abstract void TexImage2D(int target, int level, int xOffset, int yOffset, int format, int type, IImageResource image);
public abstract void TexImage2D(int target, int level, int internalFormat, int format, int type, IImageResource image);