Exemplo n.º 1
0
        /// <summary>
        /// Initializes static members of the <see cref="JsonmParser"/> class.
        /// </summary>
        static JsonmParser()
        {
            try
            {
                MImage grammar = new MImage(@"jsonm.mx");
                grammarParser = grammar.ParserFactories["jsonm.jsonm"].Create();
                grammarParser.GraphBuilder = new NodeGraphBuilder();

                // Remark: Alternate parser generation approach; dynamic compilation notably slower
                ////using (var r = new StreamReader(Environment.CurrentDirectory + @"\..\..\jsonm.mg"))
                ////{
                ////    var options = new CompilerOptions
                ////    {
                ////        Sources =
                ////        {
                ////            new TextItem
                ////            {
                ////                Name = "I Need A Name",
                ////                Reader = r,
                ////                ContentType = TextItemType.MGrammar
                ////            }
                ////        }
                ////    };

                ////    CompilationResults results = Compiler.Compile(options);
                ////    grammarParser = results.ParserFactories["jsonm.jsonm"].Create();
                ////    grammarParser.GraphBuilder = new NodeGraphBuilder();
                ////}
            }
            catch (Exception ex)
            {
                // TODO: Break and post some exception here...
            }
        }
Exemplo n.º 2
0
        private void CheckImage(int index)
        {
            if (!_initialized)
            {
                Initialize();
            }

            if (Images == null || index < 0 || index >= Images.Count)
            {
                return;
            }

            if (Images[index] == null)
            {
                _stream.Position = IndexList[index];
                Images[index]    = new MImage(_reader);
            }

            if (!Load)
            {
                return;
            }

            MImage mi = Images[index];

            if (!mi.TextureValid)
            {
                _stream.Seek(IndexList[index] + 12, SeekOrigin.Begin);
                mi.CreateTexture(_reader);
            }
        }
Exemplo n.º 3
0
 internal Language(MImage image, string moduleName, string languageName)
 {
     this.image = image;
     this.moduleName = moduleName;
     this.languageName = languageName;
     this.factory = this.image.ParserFactories[moduleName + "." + languageName];
 }
Exemplo n.º 4
0
        public void AddImage(Bitmap image, short x, short y)
        {
            MImage mImage = new MImage(image) { X = x, Y = y };

            Count++;
            Images.Add(mImage);
        }
Exemplo n.º 5
0
        public async Task <int> AddImageAsync(MImage image)
        {
            const string sql = "INSERT INTO dbo.Images (Name, ContentType, Content, UserId) " +
                               "OUTPUT INSERTED.Id " +
                               "VALUES (@Name, @ContentType, @Content, @UserId);";

            return(await connection.ExecuteScalarAsync <int>(sql, image));
        }
Exemplo n.º 6
0
		private unsafe void blendPixel(MImage image, uint size)
		{
			byte* pixels = image.pixels();
			uint i;
			for (i = 0; i < size; i++, pixels += 4)
			{
				pixels[3] = (byte)(pixels[3] * (1.0 - fTransparency));
			}
		}
Exemplo n.º 7
0
        public void ReplaceImage(int Index, Bitmap image, short x, short y)
        {
            MImage mImage = new MImage(image)
            {
                X = x, Y = y
            };

            Images[Index] = mImage;
        }
Exemplo n.º 8
0
        public void ToMLibrary()
        {
            string fileName = Path.ChangeExtension(FileName, ".Zl");

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            Mir3Library library = new Mir3Library(fileName);

            library.Images.AddRange(Enumerable.Repeat(new Mir3Library.Mir3Image(), Images.Count));
            //library.Save();

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            try
            {
                Parallel.For(0, Images.Count, options, i =>
                {
                    MImage image = Images[i];
                    if (image.HasMask)
                    {
                        library.Images[i] = new Mir3Library.Mir3Image(image.Image, null, image.MaskImage)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                        }
                    }
                    ;
                    else
                    {
                        library.Images[i] = new Mir3Library.Mir3Image(image.Image)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                        }
                    };
                });
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                library.Save(fileName);
            }

            // Operation finished.
            // System.Windows.Forms.MessageBox.Show("Converted " + fileName + " successfully.",
            //    "Wemade Information",
            //        System.Windows.Forms.MessageBoxButtons.OK,
            //            System.Windows.Forms.MessageBoxIcon.Information,
            //                System.Windows.Forms.MessageBoxDefaultButton.Button1);
        }
Exemplo n.º 9
0
        public void InsertImage(int index, Bitmap image, short x, short y)
        {
            MImage mImage = new MImage(image)
            {
                X = x, Y = y
            };

            Count++;
            Images.Insert(index, mImage);
        }
Exemplo n.º 10
0
        public void AddImage(Bitmap image, Bitmap maskImage, short x, short y)
        {
            MImage mImage = new MImage(image, maskImage)
            {
                X = x, Y = y
            };

            Count++;
            Images.Add(mImage);
        }
Exemplo n.º 11
0
        private unsafe void blendPixel(MImage image, uint size)
        {
            byte *pixels = image.pixels();
            uint  i;

            for (i = 0; i < size; i++, pixels += 4)
            {
                pixels[3] = (byte)(pixels[3] * (1.0 - fTransparency));
            }
        }
Exemplo n.º 12
0
        public void InsertImage(int index, Bitmap image, short x, short y, bool removeBlack = true)
        {
            MImage mImage = new MImage(image, removeBlack)
            {
                X = x, Y = y
            };

            Count++;
            Images.Insert(index, mImage);
        }
Exemplo n.º 13
0
        public static void MFactory_Image_DefaultValues()
        {
            string text = LinkText();
            string url  = LinkUrl();

            MImage image = MFactory.Image(text, url);

            Assert.Equal(text, image.Text);
            Assert.Equal(url, image.Url);
            Assert.Null(image.Title);
        }
Exemplo n.º 14
0
        private WaebricParser()
        {
            //Load grammar and initialize parser and graphbuilder
            String grammarPath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(WaebricParser)).CodeBase);

            grammarPath        += "\\Waebric.mx";
            grammarPath         = grammarPath.Substring(6);
            Grammar             = new MImage(grammarPath);
            Parser              = Grammar.ParserFactories["Waebric.Waebric"].Create();
            Parser.GraphBuilder = new NodeGraphBuilder();
        }
Exemplo n.º 15
0
        public static void MFactory_Image()
        {
            string text  = LinkText();
            string url   = LinkUrl();
            string title = LinkTitle();

            MImage image = MFactory.Image(text, url, title);

            Assert.Equal(text, image.Text);
            Assert.Equal(url, image.Url);
            Assert.Equal(title, image.Title);
        }
Exemplo n.º 16
0
        private async Task OnAvatarInputFileChange(InputFileChangeEventArgs e)
        {
            var imageFile = await e.File.RequestImageFileAsync(e.File.ContentType, 500, 500);

            avatarPreview = new MImage
            {
                ContentType = imageFile.ContentType,
                Name        = imageFile.Name,
                Content     = new byte[imageFile.Size]
            };
            await imageFile.OpenReadStream(2 * 1024 * 1024).ReadAsync(avatarPreview.Content);
        }
Exemplo n.º 17
0
        public VImageModel GetImage(Ctx ctx, int ad_image_id, int size)
        {
            VImageModel obj   = new VImageModel();
            MImage      mimg  = new MImage(ctx, ad_image_id, null);
            var         value = mimg.GetThumbnailByte(size, size);

            if (value != null)
            {
                obj.UsrImage = Convert.ToBase64String(value);
                //obj.UsrImage = Convert.ToBase64String(mimg.GetBinaryData());
            }
            return(obj);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Delete image
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="ad_image_id"></param>
        /// <returns></returns>
        public static int DeleteImage(Ctx ctx, int ad_image_id)
        {
            MImage mimg = new MImage(ctx, ad_image_id, null);

            if (mimg.Delete(true))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// 上传图片到服务器并更新数据库
 /// </summary>
 /// <param name="sFilePath"></param>
 /// <param name="localpath"></param>
 /// <returns>0:上传失败,1:上传成功,-1:其它错误</returns>
 public int FileUpLoad(MImage model, string localpath, bool isMarkImg)
 {
     try
     {
         int i = -2;
         if (isMarkImg)
         {
             i = fileTranfer.FileUpLoad(model.MARK_IMAGE_PATH, localpath);
         }
         else
         {
             i = fileTranfer.FileUpLoad(model.IMAGE_PATH, localpath);
         }
         if (i < 0)
         {
             return(0);
         }
         int imageId = -1;
         if (model.IMAGE_ID == null)
         {
             i = Bimage.Add(model, ref imageId);
             model.IMAGE_ID = imageId;
         }
         else
         {
             i = Bimage.Update(model, "where IMAGE_ID=" + model.IMAGE_ID);
         }
         if (i < 0)
         {
             return(0);
         }
         if (!isMarkImg)
         {
             SIS_Model.MWorkList mWorkList = (SIS_Model.MWorkList)bWorkList.GetModel(model.EXAM_ACCESSION_NUM);
             if (mWorkList.IMAGE_COUNTS == null)
             {
                 mWorkList.IMAGE_COUNTS = 1;
             }
             else
             {
                 mWorkList.IMAGE_COUNTS += 1;
             }
             bWorkList.Update(mWorkList, " where EXAM_ACCESSION_NUM = '" + mWorkList.EXAM_ACCESSION_NUM + "'");
         }
         return(1);//
     }
     catch
     {
         return(-1);
     }
 }
        public void GetImage(Ctx ctx, int ad_image_id, int size)
        {
            MImage mimg  = new MImage(ctx, ad_image_id, null);
            var    value = mimg.GetThumbnailByte(size, size);

            if (value != null)
            {
                UsrImage = Convert.ToBase64String(value);
                //obj.UsrImage = Convert.ToBase64String(mimg.GetBinaryData());
                if (mimg.GetBinaryData() != null)
                {
                    Isdatabase = true;
                }
            }
        }
Exemplo n.º 21
0
        public static void MarkdownWriter_Write_Image_NoTitle()
        {
            MarkdownWriter mw = CreateWriter();

            const string text = "ImageText";
            const string url  = "ImageUrl";

            MImage image = Image(text + Chars, url + CharsWithoutSpaces);

            string expected = $"![{text + CharsSquareBracketsBacktickLessThanEscaped}]({url + CharsWithoutSpacesParenthesesEscaped})";

            mw.Write(image);

            Assert.Equal(expected, mw.ToStringAndClear());
        }
Exemplo n.º 22
0
        public static void MarkdownWriter_WriteImage()
        {
            MarkdownWriter mw = CreateWriter();

            const string text  = "ImageText";
            const string url   = "ImageUrl";
            const string title = "ImageTitle";

            MImage image = Image(text + Chars, url + CharsWithoutSpaces, title + Chars);

            string expected = $"![{text + CharsSquareBracketsBacktickLessThanEscaped}]" +
                              $"({url + CharsWithoutSpacesParenthesesEscaped} \"{title + CharsDoubleQuoteEscaped}\")";

            mw.WriteImage(image.Text, image.Url, image.Title);

            Assert.Equal(expected, mw.ToStringAndClear());
        }
Exemplo n.º 23
0
        public override void load(MImage image, uint idx)
        {
            uint w = 512;
            uint h = 512;

            // Create a floating point image and fill it with
            // a pretty rainbow test image.
            //
            image.create(w, h, 3, MImage.MPixelType.kFloat);
            unsafe
            {
                float *pixels = image.floatPixels();
                populateTestImage(pixels, w, h);
            }

            return;
        }
Exemplo n.º 24
0
        public override void load(MImage image, uint idx)
        {
            uint w = 512;
            uint h = 512;

            // Create a floating point image and fill it with
            // a pretty rainbow test image.
            //
            image.create( w, h, 3, MImage.MPixelType.kFloat);
            unsafe
            {
                float* pixels = image.floatPixels();
                populateTestImage(pixels, w, h);
            }

            return;
        }
Exemplo n.º 25
0
        private ImgObj AddImgObj(string newFileName, string path)
        {
            MImage Mimage = new MImage();

            Mimage.EXAM_ACCESSION_NUM = frmMainForm.examInf.ExamAccessionNum;
            Mimage.IMAGE_PATH         = GetConfig.ServerImgDir + "/" + frmMainForm.examInf.ReqDateTime + "/" + frmMainForm.examInf.ExamAccessionNum + "/" + newFileName;//linux上文件保存路径
            Mimage.IMAGE_DATE         = System.DateTime.Now;
            ImageCopy imgCopy = new ImageCopy();

            if (imgCopy.FileUpLoad(Mimage, path, false) != 1)
            {
                return(null);
            }
            ImgObj imgObj = new ImgObj(path, false, Mimage);

            frmMainForm.examInf.ArrayImages.Add(imgObj);
            return(imgObj);
        }
Exemplo n.º 26
0
        public void CheckImage(int index)
        {
            if (!_initialized)
            {
                Initialize();
            }

            if (Images == null || index < 0 || index >= Images.Count)
            {
                return;
            }
            if (_stream == null)
            {
                return;
            }
            if (Images[index] == null)
            {
                _stream.Position = IndexList[index];
                Images[index]    = new MImage(_reader);
            }

            if (!Load)
            {
                return;
            }

            //MImage mi = Images[index];
            //if (!mi.TextureValid)
            //{
            //    _stream.Seek(IndexList[index] + 12, SeekOrigin.Begin);
            //    mi.CreateTexture(_reader);
            //}
            if (!Images[index].TextureValid)
            {
                _stream.Seek(IndexList[index] + 12, SeekOrigin.Begin);
                Images[index].CreateBmpTexture(_reader);
            }

            if (!Images[index].TextureValid)
            {
                _stream.Seek(IndexList[index] + 17, SeekOrigin.Begin);
                Images[index].CreateTexture(_reader);
            }
        }
Exemplo n.º 27
0
        //public static int SaveUserImage(Ctx ctx, byte[] buffer, string imageName, bool isSaveInDB, int productID)
        public static string SaveUserImage(Ctx ctx, byte[] buffer, string imageName, bool isSaveInDB, int productID)
        {
            string   imageDataURL = null;
            MProduct user         = new MProduct(ctx, productID, null);
            int      imageID      = Util.GetValueOfInt(user.GetAD_Image_ID());



            //DirectoryInfo dir = new DirectoryInfo(HostingEnvironment.MapPath("~/TempFiles/ProductImages/Thumb100x100"));
            MImage mimg = new MImage(ctx, imageID, null);

            mimg.ByteArray   = buffer;
            mimg.ImageFormat = imageName.Substring(imageName.LastIndexOf('.'));
            mimg.SetName(imageName);
            if (isSaveInDB)
            {
                mimg.SetBinaryData(buffer);
                //mimg.SetImageURL(string.Empty);
            }
            mimg.SetImageURL("Images/Thumb46x46");//Image Saved in File System so instead of byteArray image Url will be set
            if (!mimg.Save())
            {
                return("");
            }
            user.SetAD_Image_ID(mimg.GetAD_Image_ID());
            if (!user.Save())
            {
                return("");
            }
            else
            {
                string filePath = Path.Combine(HostingEnvironment.MapPath("~/Images/Thumb46x46"), mimg.GetAD_Image_ID() + mimg.ImageFormat);

                if (File.Exists(filePath))
                {
                    byte[] imageByteData   = System.IO.File.ReadAllBytes(filePath);
                    string imageBase64Data = Convert.ToBase64String(imageByteData);
                    imageDataURL = string.Format("data:image/png;base64,{0}", imageBase64Data);
                }
            }
            return(imageDataURL);
            //return mimg.GetAD_Image_ID();
        }
Exemplo n.º 28
0
        public Size GetSize(int index)
        {
            if (!_initialized)
            {
                Initialize();
            }
            if (Images == null || index < 0 || index >= Images.Count)
            {
                return(Size.Empty);
            }

            if (Images[index] == null)
            {
                _stream.Seek(IndexList[index], SeekOrigin.Begin);
                Images[index] = new MImage(_reader);
            }

            return(new Size(Images[index].Width, Images[index].Height));
        }
Exemplo n.º 29
0
		private void setDepthMap(MImage image, uint width, uint height)
		{
			float [] buffer = new float[width * height];
			uint c, j, i;
			for (c = i = 0; i < height; i++)
			{
				for (j = 0; j < width; j++, c++)
				{
					if (i > height / 2)
					{
						buffer[c] = -1.0f;
					}
					else
					{
						buffer[c] = 0.0f;
					}
				}
			}
			image.setDepthMap(buffer, width, height);
		}
Exemplo n.º 30
0
        public Point GetOffSet(int index)
        {
            if (!_initialized)
            {
                Initialize();
            }

            if (Images == null || index < 0 || index >= Images.Count)
            {
                return(Point.Empty);
            }

            if (Images[index] == null)
            {
                _stream.Seek(IndexList[index], SeekOrigin.Begin);
                Images[index] = new MImage(_reader);
            }

            return(new Point(Images[index].X, Images[index].Y));
        }
Exemplo n.º 31
0
        public void MergeToMLibrary(Mir3Library lib, int newImages)
        {
            int offset = lib.Images.Count;

            for (int i = 0; i < Images.Count; i++)
            {
                lib.Images.Add(null);
            }

            ParallelOptions options = new ParallelOptions {
                MaxDegreeOfParallelism = 8
            };

            try
            {
                Parallel.For(0, Images.Count, options, i =>
                {
                    MImage image = Images[i];
                    if (image.HasMask)
                    {
                        lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image, null, image.MaskImage)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                        }
                    }
                    ;
                    else
                    {
                        lib.Images[i + offset] = new Mir3Library.Mir3Image(image.Image)
                        {
                            OffSetX = image.X, OffSetY = image.Y, ShadowOffSetX = image.ShadowX, ShadowOffSetY = image.ShadowY
                        }
                    };
                });
                lib.AddBlanks(newImages);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Exemplo n.º 32
0
        private static bool EnsureParser()
        {
            if (_parser != null)
            {
                return(true);
            }

            try
            {
                var assembly = Assembly.GetExecutingAssembly();
                var grammar  = (from name in assembly.GetManifestResourceNames()
                                where name.EndsWith("ExpressionLanguage.mx")
                                select name).Single();

                var stream = assembly.GetManifestResourceStream(grammar);
                if (stream == null)
                {
                    return(false);
                }

                using (stream)
                {
                    using (var image = new MImage(stream, true))
                    {
                        var factory = image.ParserFactories["Supremacy.Scripting.ExpressionLanguage"];
                        _parser = factory.Create();
                    }
                }

                _xamlTypeMap = assembly
                               .GetTypes()
                               .Where(o => o.Namespace == "Supremacy.Scripting.Ast" && o.IsPublic && !o.IsAbstract)
                               .ToDictionary(o => (Identifier)o.Name, o => o);

                return(true);
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 33
0
        /// <summary>
        /// 保存图片并记录入图片表(注意是否打勾)
        /// </summary>
        /// <param name="arrayImg"></param>
        public bool SaveImage(List <ImgObj> arrayImg, SIS_Model.MWorkList worklist)
        {
            bool isSuccess = true;
            int  j         = 0;

            for (int i = 0; i < arrayImg.Count; i++)
            {
                ImgObj obj   = (ImgObj)arrayImg[i];
                MImage model = (MImage)obj.MImage;
                if (model == null)
                {
                    model                    = new MImage();
                    model.IMAGE_PATH         = CreateServerPath(obj.ImagePath);
                    model.EXAM_ACCESSION_NUM = worklist.EXAM_ACCESSION_NUM;
                }
                else
                {
                    model.IMAGE_PATH = CreateServerPath(obj.ImagePath);
                }
                model.IS_PRINT   = (obj.IsCheck == true ? 1 : 0);
                model.IMAGE_DATE = System.DateTime.Now;
                if (obj.IsDeleted)
                {
                    imgCopy.DeleteImg(model);
                }
                else
                {
                    if (imgCopy.FileUpLoad(model, obj.ImagePath, false) != 1)
                    {
                        // MessageBox.Show("图片" + obj.ImagePath + "保存失败,请检查网络连接情况", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        isSuccess = false;
                    }
                    else
                    {
                        j++;
                    }
                }
            }
            worklist.IMAGE_COUNTS = j;
            return(isSuccess);
        }
Exemplo n.º 34
0
        public Bitmap GetPreview(int index)
        {
            if (index < 0 || index >= Images.Count)
            {
                return(new Bitmap(1, 1));
            }

            MImage image = Images[index];

            if (image == null || image.Image == null)
            {
                return(new Bitmap(1, 1));
            }

            if (image.Preview == null)
            {
                image.CreatePreview();
            }

            return(image.Preview);
        }
Exemplo n.º 35
0
        private void setDepthMap(MImage image, uint width, uint height)
        {
            float [] buffer = new float[width * height];
            uint     c, j, i;

            for (c = i = 0; i < height; i++)
            {
                for (j = 0; j < width; j++, c++)
                {
                    if (i > height / 2)
                    {
                        buffer[c] = -1.0f;
                    }
                    else
                    {
                        buffer[c] = 0.0f;
                    }
                }
            }
            image.setDepthMap(buffer, width, height);
        }
Exemplo n.º 36
0
        /// <summary>
        /// 更新指定的图像记录
        /// </summary>
        /// <param name="iimage"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        public override int Update(IModel iimage, string where)
        {
            MImage    image = (MImage)iimage;
            Hashtable ht    = new Hashtable();

            ht.Add("IMAGE_ID", image.IMAGE_ID);
            ht.Add("EXAM_ACCESSION_NUM", image.EXAM_ACCESSION_NUM);
            ht.Add("IMAGE_PATH", image.IMAGE_PATH);
            ht.Add("IMAGE_TYPE", image.IMAGE_TYPE);
            ht.Add("BACK_ID", image.BACK_ID);
            ht.Add("VOLUMN_KEY", image.VOLUMN_KEY);
            ht.Add("ONLINE_ID", image.ONLINE_ID);
            ht.Add("IMAGE_CLASS", image.IMAGE_CLASS);
            ht.Add("IMAGE_EXPLAIN", image.IMAGE_EXPLAIN);
            ht.Add("IS_PRINT", image.IS_PRINT);
            ht.Add("PAGE_ORDER", image.PAGE_ORDER);
            ht.Add("MARK_INF", image.MARK_INF);
            ht.Add("IMAGE_TIME", image.IMAGE_DATE);
            ht.Add("MARK_IMAGE_PATH", image.MARK_IMAGE_PATH);
            return(ExecuteSql(StringConstructor.UpdateSql(TableName, ht, where).ToString()));
        }
Exemplo n.º 37
0
		public override void loadImageMap(string fileName, int frame, MImage image)
		{
			image.readFromFile(fileName);

			uint width;
			uint height;
			image.getSize(out width, out height);
			uint size = width * height;

			blendPixel(image, size);

			MPlug depthMap = new MPlug(thisMObject(), useDepthMap);
			bool value = false;
			depthMap.getValue(ref value);

			if (value)
			{
				setDepthMap(image, width, height);
			}
			return;
		}
Exemplo n.º 38
0
        public void ReplaceImage(int Index, Bitmap image, short x, short y)
        {
            MImage mImage = new MImage(image) { X = x, Y = y };

            Images[Index] = mImage;
        }
Exemplo n.º 39
0
        public void InsertImage(int index, Bitmap image, short x, short y)
        {
            MImage mImage = new MImage(image) { X = x, Y = y };

            Count++;
            Images.Insert(index, mImage);
        }
Exemplo n.º 40
0
        public Size GetSize(int index)
        {
            if (!_initialized)
                Initialize();
            if (Images == null || index < 0 || index >= Images.Count)
                return Size.Empty;

            if (Images[index] == null)
            {
                _stream.Seek(IndexList[index], SeekOrigin.Begin);
                Images[index] = new MImage(_reader);
            }

            return new Size(Images[index].Width, Images[index].Height);
        }
Exemplo n.º 41
0
        public Point GetOffSet(int index)
        {
            if (!_initialized)
                Initialize();

            if (Images == null || index < 0 || index >= Images.Count)
                return Point.Empty;

            if (Images[index] == null)
            {
                _stream.Seek(IndexList[index], SeekOrigin.Begin);
                Images[index] = new MImage(_reader);
            }

            return new Point(Images[index].X, Images[index].Y);
        }
Exemplo n.º 42
0
        private void CheckImage(int index)
        {
            if (!_initialized)
                Initialize();

            if (Images == null || index < 0 || index >= Images.Count)
                return;

            if (Images[index] == null)
            {
                _stream.Position = IndexList[index];
                Images[index] = new MImage(_reader);
            }

            if (!Load) return;

            MImage mi = Images[index];
            if (!mi.TextureValid)
            {
                _stream.Seek(IndexList[index] + 12, SeekOrigin.Begin);
                mi.CreateTexture(_reader);
            }
        }
        public override void glBind(MDagPath shapePath)
        {
            // ONLY push and pop required attributes performance reasons...
            //
            OpenGL.glPushAttrib(OpenGL.GL_LIGHTING_BIT);

            lightingOn = OpenGL.glIsEnabled(OpenGL.GL_LIGHTING);
            if (lightingOn > 0)
            {
                OpenGL.glEnable(OpenGL.GL_COLOR_MATERIAL);
                OpenGL.glColorMaterial(OpenGL.GL_FRONT_AND_BACK, OpenGL.GL_DIFFUSE);
            }

            // Base colour is always white
            OpenGL.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

            // Bind texture
            if(libOpenMayaNet.MAYA_API_VERSION >= 800)
            {
                MObject l_object =  shapePath.node;
                MFnMesh mesh = new MFnMesh(l_object);
                String uvSetName = "map1";
                MObjectArray textures = new MObjectArray();

                boundTexture = false;
                mesh.getAssociatedUVSetTextures(uvSetName, textures);
                if (textures.length > 0)
                {
                    MImageFileInfo.MHwTextureType hwType = new MImageFileInfo.MHwTextureType();
                    MHwTextureManager.glBind(textures[0], ref hwType);
                    boundTexture = true;
                }

                if( !boundTexture)
                {
                    OpenGL.glDisable(OpenGL.GL_TEXTURE_2D);
                    OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, 0);
                }
            }
            else
            {
                // To get this code branch to compile, replace <change file name here>
                // with an appropriate file name
                if (id == 0)
                {
                    MImage fileImage = new MImage();
                    fileImage.readFromFile("<change file name here>");
                    uint[] param = new uint[1];
                    OpenGL.glGenTextures(1, param);
                    id = param[0];
                    OpenGL.glEnable(OpenGL.GL_TEXTURE_2D);
                    OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, id);
                    unsafe
                    {
                        uint width = 0, height = 0;
                        fileImage.getSize(out width, out height);
                        byte* pPixels = fileImage.pixels();
                        OpenGL.glTexImage2D(OpenGL.GL_TEXTURE_2D,
                                            0,
                                            (int)OpenGL.GL_RGBA8,
                                            (int)width,
                                            (int)height,
                                            0,
                                            OpenGL.GL_RGBA,
                                            OpenGL.GL_UNSIGNED_BYTE,
                                            pPixels);
                    }
                }
                else
                {
                    OpenGL.glEnable(OpenGL.GL_TEXTURE_2D);
                    OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, id);
                }
                boundTexture = true;

            }

            if( boundTexture)
            {
                OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, (int)OpenGL.GL_REPEAT);
                OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, (int)OpenGL.GL_REPEAT);
                OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, (int)OpenGL.GL_LINEAR);
                OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, (int)OpenGL.GL_LINEAR);
            }
            OpenGL.glEnableClientState(OpenGL.GL_VERTEX_ARRAY);

            return;
        }
Exemplo n.º 44
0
 public static Language Load(MImage image, string moduleName, string languageName)
 {
     return new Language(image, moduleName, languageName);
 }