Ejemplo n.º 1
0
        /// <summary>
        /// Call this method to see if the DIB appears to be a normal map.
        /// </summary>
        /// <param name="bitmap"></param>
        /// <param name="bLossyCompressionSource">True if the source of the bitmap is an image with lossy compression (e.g. jpg). False otherwise.  The check will be less strict if the image can contain errors due to lossy compression.</param>
        /// <param name="bPositiveZComponent">True if the image is a normal map with the z-component mapped to the range 0 .. +1.  False if the image is a normal map with the z-component mapped to the range -1 .. +1.</param>
        /// <returns>Returns true if the bitmap appears to be a normal map. False otherwise.</returns>
        public static bool IsNormalMap(this System.Drawing.Bitmap bitmap, bool bLossyCompressionSource, out bool bPositiveZComponent)
        {
            var dib = RhinoDib.FromBitmap(bitmap);

            bool bz = false;

            bool rc = UnsafeNativeMethods.CRhinoDib_IsNormalMap(dib.ConstPointer, bLossyCompressionSource, ref bz);

            bPositiveZComponent = bz;
            return(rc);
        }
 /// <summary>
 /// Creates a preview image of the page.
 /// </summary>
 /// <param name="size">The size of the preview image.</param>
 /// <param name="grayScale">Set true to produce a grayscale image, false to produce a color image.</param>
 /// <returns>A bitmap if successful, null othewise.</returns>
 public System.Drawing.Bitmap GetPreviewImage(System.Drawing.Size size, bool grayScale)
 {
     using (var dib = new RhinoDib())
     {
         var ptr_dib = dib.NonConstPointer;
         if (UnsafeNativeMethods.CRhinoPageView_GetPreviewImage(RuntimeSerialNumber, size.Width, size.Height, grayScale, ptr_dib))
         {
             var bitmap = dib.ToBitmap();
             return(bitmap);
         }
         return(null);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Use this function to convert a System.Drawing.Bitmap from a bump to a normal texture
        /// </summary>
        /// <param name="bitmap"></param>
        /// <param name="bLossyCompressionSource">True if the source of the bitmap is an image with lossy compression (e.g. jpg). False otherwise.  The check will be less strict if the image can contain errors due to lossy compression.</param>
        /// <param name="bPositiveZComponent">True if the image is a normal map with the z-component mapped to the range 0 .. +1.  False if the image is a normal map with the z-component mapped to the range -1 .. +1.</param>
        public static System.Drawing.Bitmap ConvertToNormalMap(this System.Drawing.Bitmap bitmap, bool bLossyCompressionSource, out bool bPositiveZComponent)
        {
            var dib = RhinoDib.FromBitmap(bitmap);

            bool bz = false;

            UnsafeNativeMethods.CRhinoDib_ConvertToNormalMap(dib.ConstPointer, bLossyCompressionSource, ref bz);

            bPositiveZComponent = bz;

            var ret = RhinoDib.ToBitmap(dib.ConstPointer, false);

            dib.Dispose();

            return(ret);
        }