private static int loadImage(string filename, bool loadAlpha) { bool exists = File.Exists(filename); bool flip = false; if (!exists) { new Problem(ProblemTypes.WARNING, "Failed to load texture \"" + filename + "\"."); return(0); } int img = IL.GenImage(); IL.BindImage(img); IL.LoadImage(filename); if (flip) { ILU.FlipImage(); } IL.ConvertImage(ChannelFormat.RGBA, ChannelType.UnsignedByte); int imageWidth = IL.GetInteger(IntName.ImageWidth); int imageHeight = IL.GetInteger(IntName.ImageHeight); int texID = RawLoadImage(imageWidth, imageHeight, (PixelFormat)IL.GetInteger(IntName.ImageFormat), PixelType.UnsignedByte, IL.GetData(), loadAlpha); IL.DeleteImage(img); IL.BindImage(0); return(texID); }
public void ResizeToNearestPowerOfTwo(SamplingFilter filter, bool regenerateMipMaps) { int width = Width; int height = Height; int depth = Depth; width = MemoryHelper.RoundToNearestPowerOfTwo(width); height = MemoryHelper.RoundToNearestPowerOfTwo(height); depth = MemoryHelper.RoundToNearestPowerOfTwo(depth); Bind(); SamplingFilter oldFilter = ILU.GetSamplingFilter(); ILU.SetSamplingFilter(filter); ILU.Scale(width, height, depth); if (regenerateMipMaps) { Bind(); ILU.BuildMipMaps(); } ILU.SetSamplingFilter(oldFilter); }
public void Apply() { if (!ILU.IsInitialized) { return; } ILU.SetLanguage(this.m_language); }
public bool Mirror(Image image) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Mirror()); }
public bool FlipImage(Image image) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.FlipImage()); }
public bool Noisify(Image image, float tolerance) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Noisify(tolerance)); }
public bool SwapColors(Image image) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.SwapColors()); }
public bool ScaleColors(Image image, float red, float green, float blue) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.ScaleColors(red, green, blue)); }
public bool Scale(Image image, int width, int height, int depth) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Scale(width, height, depth)); }
public bool EnlargeCanvas(Image image, int width, int height, int depth) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.EnlargeCanvas(width, height, depth)); }
public bool BlurGaussian(Image image, int iterations) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.BlurGaussian(iterations)); }
public bool Alienify(Image image) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Alienify()); }
public bool Wave(Image image, float angle) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Wave(angle)); }
public bool Sharpen(Image image, float factor, int iterations) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Sharpen(factor, iterations)); }
public bool Saturate(Image image, float red, float green, float blue, float saturation) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Saturate(red, green, blue, saturation)); }
public bool Saturate(Image image, float saturation) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Saturate(saturation)); }
public bool Pixelize(Image image, int pixelSize) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Pixelize(pixelSize)); }
public bool Rotate3D(Image image, float x, float y, float z, float angle) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Rotate3D(x, y, z, angle)); }
public bool Crop(Image image, int offsetX, int offsetY, int offsetZ, int width, int height, int depth) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Crop(offsetX, offsetY, offsetZ, width, height, depth)); }
public bool BuildMipMaps(Image image) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.BuildMipMaps()); }
public bool EnlargeImage(Image image, int xDim, int yDim, int zDim) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.EnlargeImage(xDim, yDim, zDim)); }
public bool Contrast(Image image, float contrast) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Contrast(contrast)); }
public bool ScaleAlpha(Image image, float scale) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.ScaleAlpha(scale)); }
public bool Convolution(Image image, int[] matrix, int scale, int bias) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Convolution(matrix, scale, bias)); }
public bool ReplaceColor(Image image, byte red, byte green, byte blue, float tolerance) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.ReplaceColor(red, green, blue, tolerance)); }
public bool GammaCorrect(Image image, float gamma) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.GammaCorrect(gamma)); }
public bool EdgeDetectP(Image image) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.EdgeDetectP()); }
public bool InvertAlpha(Image image) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.InvertAlpha()); }
public bool Emboss(Image image) { if (image == null || !image.IsValid) { return(false); } IL.BindImage(image.ImageID); return(ILU.Emboss()); }
private static PixImage LoadImage(int img) { var size = new V2i(IL.GetInteger(IntName.ImageWidth), IL.GetInteger(IntName.ImageHeight)); var dataType = IL.GetDataType(); var format = IL.GetFormat(); var channels = IL.GetInteger(IntName.ImageChannels); Type type; Col.Format fmt; // try to get format information if (!s_pixDataTypes.TryGetValue(dataType, out type)) { return(null); } if (!s_pixColorFormats.TryGetValue(format, out fmt)) { return(null); } // if the image has a lower-left origin flip it var mode = (OriginMode)IL.GetInteger((IntName)0x0603); if (mode == OriginMode.LowerLeft && !ILU.FlipImage()) { return(null); } // create an appropriate PixImage instance var imageType = typeof(PixImage <>).MakeGenericType(type); var pix = (PixImage)Activator.CreateInstance(imageType, fmt, size, channels); // copy the data to the PixImage var gc = GCHandle.Alloc(pix.Data, GCHandleType.Pinned); try { var ptr = IL.GetData(); ptr.CopyTo(pix.Data, 0, pix.Data.Length); } finally { gc.Free(); } // unbind and delete the DevIL image IL.BindImage(0); IL.DeleteImage(img); return(pix); }