public bool AddOutline(Texture2DContent tex) { SurfaceFormat fmt; if (!tex.Mipmaps[0].TryGetFormat(out fmt)) { return false; } if (fmt != SurfaceFormat.Color) { context_.Logger.LogImportantMessage("Converting from format {0} to Color.", fmt.ToString()); tex.ConvertBitmapType(typeof(PixelBitmapContent<Color>)); } byte[] data = tex.Mipmaps[0].GetPixelData(); int n = AddOutline(data, tex.Mipmaps[0].Width, tex.Mipmaps[0].Height); tex.Mipmaps[0].SetPixelData(data); context_.Logger.LogMessage("Converting bitmap {0}x{1} touches {2} pixels.", tex.Mipmaps[0].Width, tex.Mipmaps[0].Height, n); tex.GenerateMipmaps(true); return true; }
public override SpriteFontContent Process(Texture2DContent input, ContentProcessorContext context) { // Fallback if we aren't buiding for iOS. var platform = ContentHelper.GetMonoGamePlatform(); if (platform != MonoGamePlatform.iOS) return base.Process(input, context); SpriteFontContent content = base.Process(input, context); // TODO: This is a very lame way of doing this as we're getting compression artifacts twice, but is the quickest way to get // Compressed fonts up and running. The SpriteFontContent/Processor contains a ton // of sealed/internal classes riddled with private fields, so overriding CompressFontTexture // or even Process is tricky. This works for now, but should be replaced when the content pipeline // moves a bit further var texWidth = input.Faces[0][0].Width; var texHeight = input.Faces[0][0].Height; // Resize to square, power of two if necessary. if (texWidth != texHeight) { texHeight = texWidth = Math.Max(texHeight, texWidth); var resizedBitmap = (BitmapContent)Activator.CreateInstance(typeof(PixelBitmapContent<Color>), new object[] { texWidth, texHeight }); var textureRegion = new Rectangle(0, 0, input.Faces[0][0].Width, input.Faces[0][0].Height); BitmapContent.Copy(input.Faces[0][0], textureRegion, resizedBitmap, textureRegion); input.Faces[0].Clear(); input.Faces[0].Add(resizedBitmap); } else input.ConvertBitmapType(typeof(PixelBitmapContent<Color>)); MGTextureProcessor.ConvertToPVRTC(input, 1, true, MGCompressionMode.PVRTCFourBitsPerPixel); return content; }