示例#1
0
        public void Create(Bitmap bitmap)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException("bitmap");
            }

            // Create image from bitmap
            Image image = CoreImagingImageCodecPlugin.LoadFromBitmap(bitmap, new ImageCodecCriteria());

            // Bitmaps must be flipped
            image.FlipVertically();
            // Create with Image as usual
            Create(image);
        }
示例#2
0
        /// <summary>
        /// Create Texture2d from a Image instance.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for creating this Texture. If it null, the current context
        /// will be used.
        /// </param>
        /// <param name="bitmap">
        /// An <see cref="Bitmap"/> holding the texture data.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception throw if <paramref name="bitmap"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="bitmap"/> pixel data is not allocated (i.e. image not defined).
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Exception thrown if <paramref name="ctx"/> is null and no context is current to the calling thread.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="bitmap"/> width or height are greater than the maximum allowed for 2D textures.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if NPOT texture are not supported by <paramref name="ctx"/> (or the current context if <paramref name="ctx"/> is
        /// null), and <paramref name="image"/> width or height are not a power-of-two value.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="image"/> format (<see cref="Image.PixelFormat"/> is not a supported internal format.
        /// </exception>
        public void Create(GraphicsContext ctx, PixelLayout internalFormat, Bitmap bitmap, uint layer)
        {
            if (layer >= Depth)
            {
                throw new ArgumentOutOfRangeException("layer", "exceeding upper boundary");
            }

            // Fictive array for defining only one layer
            Image image = CoreImagingImageCodecPlugin.LoadFromBitmap(bitmap, new ImageCodecCriteria());

            // Define texture technique
            SetTechnique(new ImageTechnique(this, TextureTarget, internalFormat, image, layer));
            // Define texture
            Create(ctx);
        }
示例#3
0
        /// <summary>
        /// Create Texture2d from a Image instance.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for creating this Texture. If it null, the current context
        /// will be used.
        /// </param>
        /// <param name="image">
        /// An <see cref="Bitmap"/> holding the texture data.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception throw if <paramref name="image"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="image"/> pixel data is not allocated (i.e. image not defined).
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Exception thrown if <paramref name="ctx"/> is null and no context is current to the calling thread.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="image"/> width or height are greater than the maximum allowed for 2D textures.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if NPOT texture are not supported by <paramref name="ctx"/> (or the current context if <paramref name="ctx"/> is
        /// null), and <paramref name="image"/> width or height are not a power-of-two value.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="image"/> format (<see cref="Image.PixelFormat"/> is not a supported internal format.
        /// </exception>
        public void Create(GraphicsContext ctx, PixelLayout internalFormat, Bitmap image, uint layer)
        {
            if (layer >= Depth)
            {
                throw new ArgumentOutOfRangeException("layer", "exceeding upper boundary");
            }

            // Fictive array for defining only one layer
            Image[] images = new Image[Depth];

            images[layer] = CoreImagingImageCodecPlugin.LoadFromBitmap(image, new ImageCodecCriteria());
            // Define texture technique
            Create(internalFormat, images, false);
            // Define texture
            Create(ctx);
        }
示例#4
0
        public void Create(Bitmap bitmap)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException("bitmap");
            }
            if (ImmutableFix)
            {
                throw new InvalidOperationException("immutable storage (see GL_ARB_texture_storage)");
            }

            // Create image from bitmap
            Image image = CoreImagingImageCodecPlugin.LoadFromBitmap(bitmap, new ImageCodecCriteria());

            // Bitmaps must be flipped
            image.FlipVertically();
            // Create with Image as usual
            Create(image);
        }