예제 #1
0
        public static CanvasInformation Create(ImageData imageData)
        {
            var item = Create(imageData.Width, imageData.Height);
            item.Context.PutImageData(imageData, 0, 0);

            return item;
        }
예제 #2
0
파일: SavedData.cs 프로젝트: Zror/DatRepo
 public void getBought(string name, ImageData[] images)
 {
     if (name.Equals("wings"))
     {
         for (int i = 0; i < wings.Count; i++)
         {
             if ((bool)wings[i])
                 images[i].buy();
         }
     }
     if (name.Equals("perks"))
     {
         for (int i = 0; i < perks.Count; i++)
         {
             if((bool)perks[i])
                 images[i].buy();
         }
     }
     if (name.Equals("breath"))
     {
         for (int i = 0; i < breath.Count; i++)
         {
            if((bool)breath[i])
                 images[i].buy();
         }
     }
     if (name.Equals("skins"))
     {
         for (int i = 0; i < skins.Count ; i++)
         {
             if((bool)skins[i]) images[i].buy();
         }
     }
 }
예제 #3
0
        static void Main(string[] args)
        {
            Notification notification = new System.Windows.Desktop.Notification();
            notification.HeaderText = "Self-Host Vote";
            notification.BodyText = "You have been using this Longhorn build for a few hours now.  By using the Vote Now button below, you can vote to let us know what you think of it.  To learn more, click this text.";

            notification.IsBodyClickable = true;
            NotificationButton notificationButton = new NotificationButton();
            notificationButton.Text = "Vote Now";
            notification.AddButton(notificationButton);

            NotificationButton notificationButton1 = new NotificationButton();
            notificationButton1.Text = "Later";
            notification.AddButton(notificationButton1);

            // Image
            try
            {
                FileStream fs = File.Open("ThumbsUp.png", FileMode.Open, FileAccess.Read, FileShare.None);
                ImageData imageData = new ImageData(fs);
                notification.HeaderIcon = imageData;
            }
            catch (Exception e) { Console.WriteLine(e); }

            notification.Send();
        }
예제 #4
0
        IEnumerator DownloadAsTexture(ImageData imageData)
        {
            Debug.Log ("[JplImageLoader] download next image: " + imageData.Url);

            WWW www = new WWW (imageData.Url);

            while (www.progress < 1 && onImageLoadingProgress != null) {
                onImageLoadingProgress (www.progress);
                yield return null;
            }

            yield return www;

            if (www.error == null) {
                imageData.Texture = www.texture;

                if (onImageLoadingComplete != null) {
                    onImageLoadingComplete (imageData);
                }
            } else {
                if (onImageLoadingError != null) {
                    onImageLoadingError (www.error);
                }
            }
        }
예제 #5
0
        public Point? Find(Bitmap findBitmap)
        {
            if (sourceImage == null || findBitmap == null)
                throw new InvalidOperationException();

            findImage = new ImageData(findBitmap);
            findImage.PixelMaskTable(this.Variation);

            var SourceRect = new Rectangle(new Point(0, 0), sourceImage.Size);
            var NeedleRect = new Rectangle(new Point(0, 0), findImage.Size);

            if (SourceRect.Contains(NeedleRect))
            {
                resets = new ManualResetEvent[threads];
                Provider = new CoordProvider(sourceImage.Size, NeedleRect.Size);

                for (int i = 0; i < threads; i++)
                {
                    resets[i] = new ManualResetEvent(false);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(ImageWorker), i);
                }

                WaitHandle.WaitAll(resets);

                return match;
            }

            return null;
        }
예제 #6
0
 private string GrayscaleImage(ICanvasRenderingContext2D ctx)
 {
     var img = new ImageData();
     img.src = "pet.jpg";
     grayscale(img, ctx);
     return @"Originals\Images\grayscale.png";
 }
예제 #7
0
    public void ChangeImageData(ImageData imageData)
    {
        SetTexture (imageData);
        SetDescriptionText (imageData);
        SetInfoText (imageData);

        loader.Hide ();
    }
예제 #8
0
 public static GameImage FromImageData(ImageData imageData)
 {
     return new GameImage
                {
                    Name = "Google",
                    URL = imageData.Url
                };
 }
        /// <summary>
        /// Gets Color32 array from texture. Generates texture if not present.
        /// Origin 0,0 will always be at Unity texture bottom-left.
        /// </summary>
        /// <param name="imageData">Source ImageData.</param>
        /// <returns>Color32 array.</returns>
        public static Color32[] GetColors(ImageData imageData)
        {
            // Generate texture if not present
            if (imageData.texture == null)
                UpdateTexture(ref imageData);

            return imageData.texture.GetPixels32();
        }
예제 #10
0
파일: Rename.cs 프로젝트: madeso/ImBatch
 public override void Apply(ImageData img)
 {
     var f = this.pattern;
     foreach (var v in img.Params)
     {
         f = f.Replace("[" + v.Key + "]", v.Value);
     }
     img.Filename = f;
 }
예제 #11
0
 public ImageDataExport(ImageData data)
 {
     ImageFile = data.Filename;
     Frames = new List<ImageFrameExport>(data.Children.Count);
     foreach (var frame in data.Children.Cast<ImageFrame>())
     {
         Frames.Add(new ImageFrameExport(frame));
     }
 }
예제 #12
0
        public LTextureList(Stream ins0)
        {
            this.imageList = new Dictionary<string, ImageData>(10);
            this.autoExpand = false;
            this.visible = true;

            int index = 0;

            string x = "x", y = "y", w = "w", h = "h";
            string scale = "scale", src = "src", maskName = "mask", empty = "empty";
            string name = "name", filterName = "filter", n = "nearest", l = "linear";

            XMLDocument doc = XMLParser.Parse(ins0);
            List<XMLElement> images = doc.GetRoot().Find("image");

            if (images.Count > 0) {
                IEnumerator<XMLElement> it = images.GetEnumerator();
                for (; it.MoveNext();) {
                    XMLElement ele = it.Current;
                    if (ele != null) {
                        ImageData data = new ImageData();
                        data.x = ele.GetIntAttribute(x, 0);
                        data.y = ele.GetIntAttribute(y, 0);
                        data.w = ele.GetIntAttribute(w, 0);
                        data.h = ele.GetIntAttribute(h, 0);
                        data.scale = ele.GetFloatAttribute(scale, 0);
                        data.xref = ele.GetAttribute(src, empty);
                        XMLElement mask = ele.GetChildrenByName(maskName);
                        if (mask != null) {
                            int r = mask.GetIntAttribute("r", 0);
                            int g = mask.GetIntAttribute("g", 0);
                            int b = mask.GetIntAttribute("b", 0);
                            int a = mask.GetIntAttribute("a", 0);
                            data.mask = new LColor(r, g, b, a);
                        } else {
                            data.mask = null;
                        }
                        string filter = ele.GetAttribute(filterName, n);
                        if (filter.Equals(n)) {
                            data.scaleType = 0;
                        }
                        if (filter.Equals(l)) {
                            data.scaleType = 1;
                        }
                        data.index = index;
                        XMLElement parent = ele.GetParent();
                        if (parent != null) {
                            CollectionUtils.Put(imageList, parent.GetAttribute(name, empty), data);
                            index++;
                        }
                    }
                }
            }
            this.count = imageList.Count;
            this.values = new LTextureObject[count];
        }
예제 #13
0
        public static CollabPacket BuildCollabPacket(string message, ImageData imageData)
        {
            CollabPacket p = new CollabPacket
            {
                Message = message,
                //ImgData = GetByteArrayFromImageData(imageData)
            };

            return p;
        }
예제 #14
0
 void SetInfoText(ImageData imageData)
 {
     infoHeadline.text = "Info";
     infoText.text = "";
     SetInfoTextLine ("Date", imageData.Date);
     SetInfoTextLine ("Category", imageData.Category);
     SetInfoTextLine ("Mission", imageData.Mission);
     SetInfoTextLine ("Views", imageData.Views.ToString ());
     SetInfoTextLine ("Credit", imageData.Credit);
 }
예제 #15
0
       public Bitmap(int w, int h)
       {
           width = w;
           height = h;

           canvas = (CanvasElement) Document.GetElementById("canvas");
           context = (CanvasRenderingContext2D) canvas.GetContext(CanvasContextId.Render2D); // "2d"    
           context.GlobalCompositeOperation = CompositeOperation.Copy;  // ### it was: CompositeOperation         
           imagedata = context.CreateImageData(w,1);  // w,h
       }
예제 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CoderFox"/> class.
        /// </summary>
        /// <param name="keyPath">A string containing the path to the image that serves as key.</param>
        internal CoderSeal(string keyPath)
            : base(keyPath)
        {
            // Get image data
                        using (Bitmap keyFile = (Bitmap)Bitmap.FromFile(_keyPath))
                _imageData = new ImageData(keyFile);

            // Set default field values
            _colorTracker = ColorCode.Red;
        }
예제 #17
0
        private static TimeSpan Threshold(ImageData data, int threshold, BackgroundWorker backgroundWorker) {
            int i = 0;
            int j = 0;
            int r = 0;
            int g = 0;
            int b = 0;
            int index = 0;

            // Lock the bitmap's bits.  
            BitmapData bmpData = data.M_bitmap.LockBits(new Rectangle(0, 0, data.M_width, data.M_height), ImageLockMode.ReadWrite, data.M_bitmap.PixelFormat);

            // Get the address of the first line.
            IntPtr ptr = bmpData.Scan0;

            // Declare an array to hold the bytes of the bitmap. 
            int bytes = Math.Abs(bmpData.Stride)*data.M_bitmap.Height;
            byte[] rgbValues = new byte[bytes];

            // Copy the RGB values into the array.
            Marshal.Copy(ptr, rgbValues, 0, bytes);

            Stopwatch watch = Stopwatch.StartNew();

            #region Algorithm
            for (i = 0; i < data.M_width; i++) {
                backgroundWorker.ReportProgress(Convert.ToInt32(((double)i/data.M_width)*100));
                for (j = 0; j < data.M_height; j++) {
                    index = (j*bmpData.Stride) + (i*3);

                    r = rgbValues[index + 2];
                    g = rgbValues[index + 1];
                    b = rgbValues[index];

                    r = r < threshold ? 0 : 255;
                    g = g < threshold ? 0 : 255;
                    b = b < threshold ? 0 : 255;

                    rgbValues[index + 2] = (byte)r;
                    rgbValues[index + 1] = (byte)g;
                    rgbValues[index] = (byte)b;
                }
            }
            #endregion

            watch.Stop();
            TimeSpan elapsedTime = watch.Elapsed;

            // Copy the RGB values back to the bitmap
            Marshal.Copy(rgbValues, 0, ptr, bytes);

            // Unlock the bits.
            data.M_bitmap.UnlockBits(bmpData);

            return elapsedTime;
        }
예제 #18
0
        private string sample17(ICanvasRenderingContext2D ctx)
        {
            // create new image object to use as pattern
            IImageData img = new ImageData();
            img.src = @"wallpaper.png";

            // create pattern
            object ptrn = ctx.createPattern(img, "repeat");
            ctx.fillStyle = ptrn;
            ctx.fillRect(0, 0, 150, 150);
            return @"Originals\Images\sample17.png";
        }
예제 #19
0
    protected override void OnShown()
    {
        base.OnShown ();

        imagedata = new ImageData ();
        formsimage1.DataBindings.Add ("ImageData", imagedata, "Pixdata",
            false, DataSourceUpdateMode.OnPropertyChanged);
        Pixbuf pixbuf = new Pixbuf ("logo.png");
        Pixdata pixdata = new Pixdata ();
        pixdata.FromPixbuf (pixbuf, false);
        imagedata.Pixdata = pixdata.Serialize();
    }
예제 #20
0
 private static void QueueNewImage(MemoryStream memoryStream, int height, int width, string source)
 {
     var img = new ImageData
     {
         Name = source,
         Data = memoryStream.ToArray(),
         Height = height,
         Width = width,
         Timestamp = DateTime.UtcNow
     };
     var message = new BrokeredMessage(img);
     QueueConnector.ImageQueueClient.BeginSend(message, SendComplete, img.FormattedName);
 }
예제 #21
0
 private void button1_Click(object sender, EventArgs e)
 {
     ImageData Idata = new ImageData();
     Idata = Search(textBox1.Text);
     if (Idata.id != 5000)
     {
         AddToRows(Idata.Name, Idata.Location, Idata.Tags.ToString());//Fix tags
     }
     else
     {
         MessageBox.Show("No Images found.");
     }
 }
예제 #22
0
파일: ImagePGA.cs 프로젝트: Casidi/GARbro
 public override void Write(Stream file, ImageData image)
 {
     using (var png = new MemoryStream())
     {
         base.Write (png, image);
         var buffer = png.GetBuffer();
         for (int i = 0; i < 8; ++i)
             buffer[i+8] ^= (byte)"PGAECODE"[i];
         buffer[5] = (byte)'P';
         buffer[6] = (byte)'G';
         buffer[7] = (byte)'A';
         file.Write (buffer, 5, (int)png.Length - 5);
     }
 }
예제 #23
0
        private string PatternAndTransformation(ICanvasRenderingContext2D ctx)
        {
            // create new image object to use as pattern
            IImageData img = new ImageData();
            img.src = @"wallpaper.png";

            // create pattern
            object ptrn = ctx.createPattern(img, "repeat");
            ctx.translate(50, 0);
            ctx.rotate(Math.PI*2/(6));
            ctx.fillStyle = ptrn;
            ctx.fillRect(0, 0, 150, 150);
            return @"Originals\Images\PatternAndTransformation.png";
        }
예제 #24
0
 ImageData ConstructImageData(Item item)
 {
     string url = IMAGE_BASE_URL + item.images.thumb.src.Replace ("640x350", "1280x1024");
     ImageData imageData = new ImageData (url);
     imageData.Title = HttpUtility.HtmlDecode (item.title);
     imageData.Description = HttpUtility.HtmlDecode (item.tease);
     imageData.Credit = item.credit;
     imageData.Category = item.category;
     imageData.Date = item.date;
     imageData.Mission = item.mission;
     imageData.MissionLink = item.mission_link;
     imageData.Views = item.views;
     return imageData;
 }
예제 #25
0
 private void LoadImage(string FilePath, string FileName, string[] tags)
 {
     ImageData Idata = new ImageData();
     Idata.id = 0;//Just for now
     Idata.Location = FilePath;
     Idata.Name = FileName;
     Idata.Tags = new List<string>();
     foreach (string s in tags)
     {
         Idata.Tags.Add(s);
     }
     Images.Add(Idata);
     AddToRows(FileName, FilePath, tags.ToString());//Fix tags
 }
예제 #26
0
파일: ImageBMZ.cs 프로젝트: Casidi/GARbro
 public override void Write(Stream file, ImageData image)
 {
     using (var bmp = new MemoryStream())
     {
         base.Write (bmp, image);
         using (var output = new BinaryWriter (file, Encoding.ASCII, true))
         {
             output.Write (Signature);
             output.Write ((uint)bmp.Length);
         }
         bmp.Position = 0;
         using (var zstream = new ZLibStream (file, CompressionMode.Compress, CompressionLevel.Level9, true))
             bmp.CopyTo (zstream);
     }
 }
 public MainWindow()
 {
     InitializeComponent();
     vkApi = VKAPI.Instance;
     data = new DownloadData()
     {
         UserID = "1"
     };
     imgData = new ImageData();
     tr = TranslationManager.Instance;
     this.albumURL.DataContext = data;
     this.saveDir.DataContext = data;
     this.languageSelector.DataContext = tr;
     tr.CurrentLanguage = tr.Languages.First(a => a.TwoLetterISOLanguageName == tr.CurrentLanguage.TwoLetterISOLanguageName);
 }
예제 #28
0
        public void Update()
        {
            var output = new DrawingGroup();
            var format = new BasicTextParagraphProperties("Times New Roman", 34, FlowDirection.LeftToRight);
            var words = BoundedWord.GetWords(Text, Measurer.MeasureLines(Text, 200, format, output)).ToList();
            Image = output.ToBitmap();

            ImageData imageData;
            using (var stream = Image.CreateStream())
                imageData = new ImageData(stream);

            var boards = imageData.DefineIteratedBoards();
            var chars = words.SelectMany(w => w.Characters);
            Segments = chars.Select(boards.GetLetterHeuristics).ToList();
        }
예제 #29
0
 public FullImageData(ImageData data)
 {
     this.CloudCoveragePercentage = data.CloudCoveragePercentage;
     this.DatasetID = data.DatasetID;
     this.Filesize = data.Filesize;
     this.Framenum = data.Framenum;
     this.Height = data.Height;
     this.Highresurl = data.Highresurl;
     this.ImageDataID = data.ImageDataID;
     this.Latitude = data.Latitude;
     this.Longitude = data.Longitude;
     this.Lowresurl = data.Lowresurl;
     this.Rollnum = data.Rollnum;
     this.Width = data.Width;
 }
예제 #30
0
 public ExperimentData(ExperimentData exp) : base(exp)
 {
     this.expID = -1;
     this.ExperimentQuestion = exp.ExperimentQuestion;
     this.Type = "Experiment";
     RoadScholarContext rsContext = new RoadScholarContext();
     this.activities = new List<ActivityData>();
     foreach (ActivityData act in exp.activities)
     {
         ActivityData copiedActivity = null;
         if (act is TrueFalseQuestionData)
         {
             copiedActivity = new TrueFalseQuestionData((TrueFalseQuestionData)act);
             rsContext.addActivity(copiedActivity);
         }
         else if (act is AmericanQuestionData)
         {
             copiedActivity = new AmericanQuestionData((AmericanQuestionData)act);
             rsContext.addActivity(copiedActivity);
         }
         else if (act is ShortAnswerQuestionData)
         {
             copiedActivity = new ShortAnswerQuestionData((ShortAnswerQuestionData)act);
             rsContext.addActivity(copiedActivity);
         }
         else if (act is InstructionData)
         {
             copiedActivity = new InstructionData((InstructionData)act);
             rsContext.addActivity(copiedActivity);
         }
         else if (act is ImageData)
         {
             copiedActivity = new ImageData((ImageData)act);
             rsContext.addActivity(copiedActivity);
         }
         else if (act is VideoData)
         {
             copiedActivity = new VideoData((VideoData)act);
             rsContext.addActivity(copiedActivity);
         }
         else if (act is MeasurementData)
         {
             copiedActivity = new MeasurementData((MeasurementData)act);
             rsContext.addActivity(copiedActivity);
         }
         this.activities.Add(copiedActivity);
     }
 }
예제 #31
0
 public override void Write(Stream file, ImageData image)
 {
     throw new NotImplementedException("SeraphCfImage.Write not implemented");
 }
예제 #32
0
 public override void UpdateImage(ImageData img) => _data = new BitArray(img.Data.ToByteArray());
예제 #33
0
        public InvasiveVisualProjectLocationFormViewModel()
        {
            RadioList_VisualReviewItems = new ObservableCollection <CustomRadioItem>();
            RadioList_VisualReviewItems.Add(new CustomRadioItem()
            {
                ID = 1, Name = "Good", IsChecked = false, GroupName = "VR"
            });
            RadioList_VisualReviewItems.Add(new CustomRadioItem()
            {
                ID = 2, Name = "Bad", IsChecked = false, GroupName = "VR"
            });
            RadioList_VisualReviewItems.Add(new CustomRadioItem()
            {
                ID = 3, Name = "Fair", IsChecked = false, GroupName = "VR"
            });

            RadioList_AnyVisualSignItems = new ObservableCollection <CustomRadioItem>();
            RadioList_AnyVisualSignItems.Add(new CustomRadioItem()
            {
                ID = 1, Name = "Yes", IsChecked = false, GroupName = "AVS"
            });
            RadioList_AnyVisualSignItems.Add(new CustomRadioItem()
            {
                ID = 2, Name = "No", IsChecked = false, GroupName = "AVS"
            });


            RadioList_FurtherInasiveItems = new ObservableCollection <CustomRadioItem>();
            RadioList_FurtherInasiveItems.Add(new CustomRadioItem()
            {
                ID = 1, Name = "Yes", IsChecked = false, GroupName = "FIR"
            });
            RadioList_FurtherInasiveItems.Add(new CustomRadioItem()
            {
                ID = 2, Name = "No", IsChecked = false, GroupName = "FIR"
            });

            RadioList_ConditionAssessment = new ObservableCollection <CustomRadioItem>();
            RadioList_ConditionAssessment.Add(new CustomRadioItem()
            {
                ID = 1, Name = "Pass", IsChecked = false, GroupName = "CA"
            });
            RadioList_ConditionAssessment.Add(new CustomRadioItem()
            {
                ID = 2, Name = "Fail", IsChecked = false, GroupName = "CA"
            });
            RadioList_ConditionAssessment.Add(new CustomRadioItem()
            {
                ID = 3, Name = "Future Inspection", IsChecked = false, GroupName = "CA"
            });

            RadioList_LifeExpectancyEEE = new ObservableCollection <CustomRadioItem>();
            RadioList_LifeExpectancyEEE.Add(new CustomRadioItem()
            {
                ID = 1, Name = "0-1 Years", IsChecked = false, GroupName = "EEE"
            });
            RadioList_LifeExpectancyEEE.Add(new CustomRadioItem()
            {
                ID = 2, Name = "1-4 Years", IsChecked = false, GroupName = "EEE"
            });
            RadioList_LifeExpectancyEEE.Add(new CustomRadioItem()
            {
                ID = 3, Name = "4-7 Years", IsChecked = false, GroupName = "EEE"
            });
            RadioList_LifeExpectancyEEE.Add(new CustomRadioItem()
            {
                ID = 4, Name = "7+ Years", IsChecked = false, GroupName = "EEE"
            });



            //RadioList_LifeExpectancyLBC = new ObservableCollection<CustomRadioItem>();
            //RadioList_LifeExpectancyLBC.Add(new CustomRadioItem() { ID = 1, Name = "0-1 Years", IsChecked = false, GroupName = "LBC" });
            //RadioList_LifeExpectancyLBC.Add(new CustomRadioItem() { ID = 2, Name = "1-4 Years", IsChecked = false, GroupName = "LBC" });
            //RadioList_LifeExpectancyLBC.Add(new CustomRadioItem() { ID = 3, Name = "4-7 Years", IsChecked = false, GroupName = "LBC" });
            //RadioList_LifeExpectancyLBC.Add(new CustomRadioItem() { ID = 4, Name = "7+ Years", IsChecked = false, GroupName = "LBC" });


            RadioList_LifeExpectancyLBC = new ObservableCollection <CustomRadioItem>();
            RadioList_LifeExpectancyLBC.Add(new CustomRadioItem()
            {
                ID = 1, Name = "0-1 Years", IsChecked = false, GroupName = "LBC"
            });
            RadioList_LifeExpectancyLBC.Add(new CustomRadioItem()
            {
                ID = 2, Name = "1-4 Years", IsChecked = false, GroupName = "LBC"
            });
            RadioList_LifeExpectancyLBC.Add(new CustomRadioItem()
            {
                ID = 3, Name = "4-7 Years", IsChecked = false, GroupName = "LBC"
            });
            RadioList_LifeExpectancyLBC.Add(new CustomRadioItem()
            {
                ID = 4, Name = "7+ Years", IsChecked = false, GroupName = "LBC"
            });


            RadioList_LifeExpectancyAWE = new ObservableCollection <CustomRadioItem>();
            RadioList_LifeExpectancyAWE.Add(new CustomRadioItem()
            {
                ID = 1, Name = "0-1 Years", IsChecked = false, GroupName = "AWE"
            });
            RadioList_LifeExpectancyAWE.Add(new CustomRadioItem()
            {
                ID = 2, Name = "1-4 Years", IsChecked = false, GroupName = "AWE"
            });
            RadioList_LifeExpectancyAWE.Add(new CustomRadioItem()
            {
                ID = 3, Name = "4-7 Years", IsChecked = false, GroupName = "AWE"
            });
            RadioList_LifeExpectancyAWE.Add(new CustomRadioItem()
            {
                ID = 4, Name = "7+ Years", IsChecked = false, GroupName = "AWE"
            });


            GoBackCommand         = new Command(async() => await GoBack());
            SaveCommand           = new Command(async() => await Save());
            ExteriorElements      = new ObservableCollection <string>();
            WaterProofingElements = new ObservableCollection <string>();
            //MessagingCenter.Subscribe<ImageEditor.Pages.ImageEditorPage, string>(this, "AddItem", async (obj, item) =>
            //{
            //    var newItem = item as string;
            //    await App.Current.MainPage.DisplayAlert(newItem,newItem,"ok","cancel");
            //});
            //LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
            //Load();
            ImgData = new ImageData();
            MessagingCenter.Subscribe <PopUpCheakListBox, ObservableCollection <string> >(this, "SelectedItem", (obj, item) =>
            {
                ExteriorElements      = item as ObservableCollection <string>;
                CountExteriorElements = ExteriorElements.Count.ToString();
            });
            MessagingCenter.Subscribe <PopUpCheakListBoxWaterProofing, ObservableCollection <string> >(this, "SelectedItem", (obj, item) =>
            {
                WaterProofingElements      = item as ObservableCollection <string>;
                CountWaterProofingElements = WaterProofingElements.Count.ToString();
            });
            //MessagingCenter.Subscribe<Camera2Forms.CameraPage, string>(this, "Count", async (obj, item) =>
            //{
            //    //UnitPhotos.Clear();
            //    //ObservableCollection <VisualProjectLocationPhoto> listTempImage = item as ObservableCollection<VisualProjectLocationPhoto>;

            //    //foreach (var data in listTempImage)
            //    //{
            //    //    UnitPhotos.Add(data);
            //    //}
            //    UnitPhotoCount = item as string;

            //});
            //MessagingCenter.Subscribe<Camera2Forms.CameraPage, ObservableCollection<MultiImage>>(this, "ImageList", async (obj, item) =>
            //{
            //    var items = item as ObservableCollection<MultiImage>;

            //    foreach (var photo in items)
            //    {
            //        VisualProjectLocationPhoto newObj = new VisualProjectLocationPhoto() { ImageUrl = photo.Image, Id = Guid.NewGuid().ToString(), VisualLocationId = VisualForm.Id };
            //        _ = AddNewPhoto(newObj);
            //     //   await VisualProjectLocationPhotoDataStore.AddItemAsync(newObj);

            //    }
            //    //await Load();
            // //   VisualProjectLocationPhotoItems = new ObservableCollection<VisualProjectLocationPhoto>(await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(VisualForm.Id));
            //    //UnitPhotoCount = VisualProjectLocationPhotoItems.Count.ToString();
            //    //  UnitPhotoCount = (await VisualProjectLocationPhotoDataStore.GetItemsAsyncByProjectVisualID(ProjectLocation.Id)).Count().ToString();

            //});
        }
예제 #34
0
        // Flood-fill textures
        public virtual void OnImageFloodfill()
        {
            if (BuilderPlug.Me.CopiedImageIndex <= -1)
            {
                return;
            }

            int oldtile = GetImageIndex();
            int newtile = BuilderPlug.Me.CopiedImageIndex;

            if (newtile == oldtile)
            {
                return;
            }

            mode.CreateUndo("Flood-fill images with image " + newtile);
            mode.SetActionResult("Flood-filled images with " + newtile + ".");

            mode.Renderer.SetCrosshairBusy(true);
            General.Interface.RedrawDisplay();

            // Get the image
            ImageData newtextureimage = General.Map.Data.GetImageData(newtile);

            if (newtextureimage == null)
            {
                return;
            }

            if (mode.IsSingleSelection)
            {
                // Clear all marks, this will align everything it can
                General.Map.Map.ClearMarkedSidedefs(false);
            }
            else
            {
                // Limit the alignment to selection only
                General.Map.Map.ClearMarkedSidedefs(true);
                List <Sidedef> sides = mode.GetSelectedWalls();
                foreach (Sidedef sd in sides)
                {
                    sd.Marked = false;
                }
            }

            // Do the alignment
            Tools.FloodfillWallImages(this.Sidedef, oldtile, newtile, false);

            // Get the changed sidedefs
            List <Sidedef> changes = General.Map.Map.GetMarkedSidedefs(true);

            foreach (Sidedef sd in changes)
            {
                // Update the parts for this sidedef!
                if (mode.VisualSectorExists(sd.Sector))
                {
                    BaseVisualSector vs    = (mode.GetVisualSector(sd.Sector) as BaseVisualSector);
                    VisualWallParts  parts = vs.GetSidedefParts(sd);
                    parts.SetupAllParts();
                }
            }

            General.Map.Data.UpdateUsedImages();
            mode.Renderer.SetCrosshairBusy(false);
            mode.ShowTargetInfo();
        }
        // GET: Todos/Delete/5
        public ActionResult GetPDF(int?id)
        {
            Trace.WriteLine("GET /Todos/GetPDF/" + id);
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Todo todo = db.Todoes.Find(id);

            if (todo == null)
            {
                return(HttpNotFound());
            }

            //string filePath = HttpRuntime.AppDomainAppPath + "/PDF/NewEmployeeDetails.pdf";
            //string filePathFilled = HttpRuntime.AppDomainAppPath + "/PDF/NewEmployeeDetailsFilled.pdf";
            string filePath       = MapPath("~/PDF/NewEmployeeDetails.pdf");
            string filePathFilled = MapPath("~/PDF/NewEmployeeDetailsFilled.pdf");

            PdfDocument pdf  = new PdfDocument(new PdfReader(filePath), new PdfWriter(filePathFilled));
            PdfAcroForm form = PdfAcroForm.GetAcroForm(pdf, true);

            PdfFont fontHELVETICA = PdfFontFactory.CreateFont(StandardFonts.HELVETICA);

            string AsAboveAddressVaule = todo.AsAboveAddress ? "Yes" : ""; // empty string is false

            form.GetField("First Name").SetValue(todo.FirstName);
            form.GetField("Last Name").SetValue(todo.LastName);
            form.GetField("Full Address").SetValue(todo.FullAddress);
            if (todo.MailingAddress != null && AsAboveAddressVaule.Length <= 0)
            {
                PdfTextFormField mailingAddress = PdfFormField.CreateText(pdf, new Rectangle(227, 607, 310, 30), "mailingAddress", todo.MailingAddress, fontHELVETICA, 18);
                form.AddField(mailingAddress);
            }
            else
            {
                form.GetField("As Above").SetCheckType(PdfFormField.TYPE_CHECK).SetValue(AsAboveAddressVaule);
            }

            form.GetField("Email Address").SetValue(todo.EmailAddress).SetJustification(PdfFormField.ALIGN_LEFT);
            PdfTextFormField phoneNumber = PdfFormField.CreateText(pdf, new Rectangle(145, 538, 392, 30), "phoneNumber", "0" + todo.PhoneNumber.ToString(), fontHELVETICA, 18);

            form.AddField(phoneNumber);
            form.GetField("Citizenship Statas").SetValue(todo.CitizenStatus).SetJustification(PdfFormField.ALIGN_LEFT);
            form.GetField("Employment Start Date").SetValue(todo.EmploymentStartDate.ToString()).SetJustification(PdfFormField.ALIGN_LEFT);
            form.GetField("Employment Type").SetValue(todo.EmploymentType).SetJustification(PdfFormField.ALIGN_LEFT);
            form.GetField("Position Title").SetValue(todo.PositionTitle).SetJustification(PdfFormField.ALIGN_LEFT);
            form.GetField("Name").SetValue(todo.EmergencyContactName);
            form.GetField("Relationship").SetValue(todo.EmergencyContactRelationship);
            PdfTextFormField emergencyContactPhoneNumber = PdfFormField.CreateText(pdf, new Rectangle(145, 275, 392, 30), "emergencyPhoneNumber", "0" + todo.EmergencyContactPhoneNumber.ToString(), fontHELVETICA, 18);

            form.AddField(emergencyContactPhoneNumber);

            if (todo.EmployeeSignature != null)
            {
                ImageData imageData = ImageDataFactory.CreatePng(todo.EmployeeSignature);
                Image     image     = new Image(imageData).ScaleAbsolute(200, 50).SetFixedPosition(1, 190, 180);
                Document  document  = new Document(pdf);
                document.Add(image);
            }

            form.FlattenFields();
            pdf.Close();

            return(File(filePathFilled, "application/pdf"));;
        }
예제 #36
0
 /// <summary>
 /// Creates an
 /// <see cref="Image"/>
 /// from an image resource, read in from a file
 /// with the iText I/O module.
 /// </summary>
 /// <param name="img">
 /// an internal representation of the
 /// <see cref="iText.IO.Image.ImageData">image resource</see>
 /// </param>
 public Image(ImageData img)
     : this(new PdfImageXObject(CheckImageType(img)))
 {
     SetProperty(Property.FLUSH_ON_DRAW, true);
 }
예제 #37
0
        /// <summary>
        /// Creates a new bugitem with the given <paramref name="details"/> and the <paramref name="pictureOfBug"/> in the repro steps
        /// </summary>
        public async Task CreateBug(BugDetails details, ImageData pictureOfBug)
        {
            const string        urlEncodedFilename = "bug-shooter-screenshot.jpeg";
            var                 bitmap             = (Bitmap)pictureOfBug.MergedImage;
            AttachmentReference attachment;

            using (var stream = ConvertBitmapToMaxQualityJpeg(bitmap))
            {
                attachment = await _workItemClient.CreateAttachmentAsync(stream, urlEncodedFilename, uploadType : "Simple",
                                                                         areaPath : null, userState : null, cancellationToken : default);
            }

            string reproAsHtml = details.ReproSteps.Replace("\n", "<br />");

            JsonPatchDocument doc = new JsonPatchDocument
            {
                new JsonPatchOperation
                {
                    Path      = TitleFieldPath,
                    Operation = Operation.Add,
                    Value     = details.Title
                },
                new JsonPatchOperation
                {
                    Path      = ReproStepsFieldPath,
                    Operation = Operation.Add,
                    Value     = $"{reproAsHtml}<br /><img src='{attachment.Url}' />"
                },
                new JsonPatchOperation
                {
                    Path      = RelationFieldPath,
                    Operation = Operation.Add,
                    Value     = new
                    {
                        rel = "AttachedFile",
                        url = attachment.Url
                    }
                }
            };

            if (!string.IsNullOrWhiteSpace(_output.IterationName))
            {
                doc.Add(new JsonPatchOperation
                {
                    Path      = IterationFieldPath,
                    Operation = Operation.Add,
                    Value     = _output.IterationName
                });
            }

            if (!string.IsNullOrEmpty(_output.BuildDefinitionName) && !string.IsNullOrEmpty(details.Build))
            {
                doc.Add(new JsonPatchOperation
                {
                    Path      = FoundInBuildFieldPath,
                    Operation = Operation.Add,
                    Value     = $"{details.Build}"
                });
            }

            await _workItemClient.CreateWorkItemAsync(doc, _output.ProjectName, WorkItemType);
        }
예제 #38
0
        // This builds the thing geometry. Returns false when nothing was created.
        public bool Setup()
        {
            // Find the sector in which the thing resides
            Thing.DetermineSector(mode.BlockMap);

            //mxd. If the thing is inside a sector, apply DECORATE/UDMF alpha/renderstyle overrides
            byte alpha = 255;

            if (Thing.Sector != null)
            {
                string renderstyle = info.RenderStyle.ToLowerInvariant();
                alpha = info.AlphaByte;

                if (General.Map.UDMF)
                {
                    if (Thing.IsFlagSet("translucent"))
                    {
                        renderstyle = "translucent";
                        alpha       = 64;
                    }
                    else if (Thing.IsFlagSet("invisible"))
                    {
                        renderstyle = "none";
                        alpha       = 0;
                    }
                    else if (Thing.Fields.ContainsKey("renderstyle"))
                    {
                        renderstyle = Thing.Fields.GetValue("renderstyle", renderstyle).ToLowerInvariant();
                    }

                    if ((renderstyle == "add" || renderstyle == "translucent" || renderstyle == "subtract" || renderstyle.EndsWith("stencil")) &&
                        Thing.Fields.ContainsKey("alpha"))
                    {
                        alpha = (byte)(General.Clamp(Thing.Fields.GetValue("alpha", info.Alpha), 0.0, 1.0) * 255.0);
                    }

                    if (renderstyle.EndsWith("stencil"))
                    {
                        stencilColor   = PixelColor.FromInt(UniFields.GetInteger(Thing.Fields, "fillcolor", 0));
                        stencilColor.a = 255; // 0xFF alpha means nothing was read. 0x00 alpha means there was a valid fillcolor.
                    }
                    else
                    {
                        stencilColor.a = 0;
                    }
                }
                else if (General.Map.HEXEN)
                {
                    if (Thing.IsFlagSet("2048"))
                    {
                        renderstyle = "translucent";
                        alpha       = 64;
                    }
                    else if (Thing.IsFlagSet("4096"))
                    {
                        renderstyle = "none";
                        alpha       = 0;
                    }
                }

                // Set appropriate RenderPass
                switch (renderstyle)
                {
                case "translucent":
                case "subtract":
                case "stencil":
                    RenderPass = RenderPass.Alpha;
                    break;

                case "add":
                case "addstencil":
                    RenderPass = RenderPass.Additive;
                    break;

                case "none":
                    RenderPass = RenderPass.Mask;
                    alpha      = 0;
                    break;

                // Many render styles are not supported yet...
                default:
                    RenderPass = RenderPass.Mask;
                    alpha      = 255;
                    break;
                }
            }

            int sectorcolor = new PixelColor(alpha, 255, 255, 255).ToInt();

            fogfactor = 0f;             //mxd

            //mxd. Check thing size
            float thingradius = Thing.Size;         // Thing.Size has ThingRadius arg override applied

            thingheight = Thing.Height;             // Thing.Height has ThingHeight arg override applied

            if (thingradius < 0.1f || thingheight < 0.1f)
            {
                thingradius = FIXED_RADIUS;
                thingheight = FIXED_RADIUS;
                sizeless    = true;
            }
            else
            {
                sizeless = false;
            }

            if (Thing.Sector != null)
            {
                SectorData sd    = mode.GetSectorData(Thing.Sector);
                Plane      floor = sd.Floor.plane;            //mxd

                if (!info.Bright)
                {
                    Vector3D    thingpos = new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + sd.Floor.plane.GetZ(Thing.Position));
                    SectorLevel level    = sd.GetLevelAboveOrAt(thingpos);

                    //mxd. Let's use point on floor plane instead of Thing.Sector.FloorHeight;
                    if (nointeraction && level == null && sd.LightLevels.Count > 0)
                    {
                        level = sd.LightLevels[sd.LightLevels.Count - 1];
                    }

                    //mxd. Use the light level of the highest surface when a thing is above highest sector level.
                    if (level != null)
                    {
                        // TECH: In GZDoom, ceiling glow doesn't affect thing brightness
                        // Use sector brightness for color shading
                        int brightness = level.brightnessbelow;

                        //mxd. Apply lightfloor value
                        // According to Graf, this is incorrect behaviour...
                        // TECH: In (G)ZDoom, this is ignored when ceiling texture is sky or a thing is below a 3D floor
                        // It's probably more involved than this, but for now let's do it only when there are no 3d floors in Thing.Sector...

                        /*if(General.Map.UDMF && sd.LightLevels.Count == 2 && Thing.Sector.CeilTexture != General.Map.Config.SkyFlatName)
                         * {
                         *      if(sd.Sector.Fields.GetValue("lightfloorabsolute", false))
                         *              brightness = UniFields.GetInteger(sd.Sector.Fields, "lightfloor");
                         *      else
                         *              brightness += UniFields.GetInteger(sd.Sector.Fields, "lightfloor");
                         * }*/

                        // Level is glowing
                        if (level.affectedbyglow && level.type == SectorLevelType.Floor)
                        {
                            // Extrafloor glow doesn't affect thing brightness
                            if (level.sector == Thing.Sector)
                            {
                                double planez = level.plane.GetZ(thingpos);

                                // Get glow brightness
                                int         glowbrightness = sd.FloorGlow.Brightness / 2;
                                SectorLevel nexthigher     = sd.GetLevelAbove(new Vector3D(thingpos, planez));

                                // Interpolate thing brightness between glow and regular ones
                                if (nexthigher != null)
                                {
                                    double higherz = nexthigher.plane.GetZ(thingpos);
                                    double delta   = General.Clamp(1.0f - (thingpos.z - planez) / (higherz - planez), 0f, 1f);
                                    brightness = (int)((glowbrightness + level.sector.Brightness / 2) * delta + nexthigher.sector.Brightness * (1.0f - delta));
                                }
                            }
                        }
                        // Level below this one is glowing. Only possible for floor glow(?)
                        else if (level.type == SectorLevelType.Glow)
                        {
                            // Interpolate thing brightness between glow and regular ones
                            if (sd.Floor != null && sd.FloorGlow != null)
                            {
                                // Get glow brightness
                                double glowz  = level.plane.GetZ(thingpos);
                                double floorz = floor.GetZ(thingpos);
                                double delta  = General.Clamp((thingpos.z - floorz) / (glowz - floorz), 0f, 1f);

                                brightness = (int)((sd.FloorGlow.Brightness / 2 + sd.Floor.sector.Brightness / 2) * (1.0f - delta) + sd.Floor.sector.Brightness * delta);
                            }
                        }

                        PixelColor areabrightness = PixelColor.FromInt(mode.CalculateBrightness(brightness));
                        PixelColor areacolor      = PixelColor.Modulate(level.colorbelow, areabrightness);

                        // [ZZ] if sector is using Doom64 lighting, apply thing color here.
                        sectorcolor = PixelColor.Modulate(sd.ColorSprites, areacolor).WithAlpha(alpha).ToInt();

                        //mxd. Calculate fogfactor
                        fogfactor = VisualGeometry.CalculateFogFactor(level.sector, brightness);
                    }
                }
                //TECH: even Bright Thing frames are affected by custom fade...
                else
                {
                    Vector3D    thingpos = new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + sd.Floor.plane.GetZ(Thing.Position));
                    SectorLevel level    = sd.GetLevelAboveOrAt(thingpos);

                    if (level != null && level.sector.FogMode > SectorFogMode.CLASSIC)
                    {
                        //mxd. Calculate fogfactor
                        fogfactor = VisualGeometry.CalculateFogFactor(level.sector, level.brightnessbelow);
                    }
                }
            }

            //mxd. Create verts for all sprite angles
            WorldVertex[][] allverts   = new WorldVertex[info.SpriteFrame.Length][];
            Vector2D[]      alloffsets = new Vector2D[info.SpriteFrame.Length];
            base.textures = new ImageData[info.SpriteFrame.Length];
            isloaded      = true;

            for (int i = 0; i < sprites.Length; i++)
            {
                Vector2D offsets = new Vector2D();

                // Check if the texture is loaded
                ImageData sprite = sprites[i];
                if (!sprite.IsImageLoaded && !sprite.LoadFailed)
                {
                    sprite.LoadImageNow();
                }
                if (sprite.IsImageLoaded)
                {
                    base.textures[i] = sprite;

                    // Determine sprite size and offset
                    float        radius    = sprite.ScaledWidth * 0.5f;
                    float        height    = sprite.ScaledHeight;
                    ISpriteImage spriteimg = sprite as ISpriteImage;
                    if (spriteimg != null)
                    {
                        offsets.x = radius - spriteimg.OffsetX;
                        offsets.y = spriteimg.OffsetY - height;
                    }

                    // Scale by thing type/actor scale
                    // We do this after the offset x/y determination above, because that is entirely in sprite pixels space
                    radius    *= info.SpriteScale.Width;
                    height    *= info.SpriteScale.Height;
                    offsets.x *= info.SpriteScale.Width;
                    offsets.y *= info.SpriteScale.Height;

                    // Make vertices
                    WorldVertex[] verts = new WorldVertex[6];

                    //mxd. Sprite mirroring
                    float ul = (info.SpriteFrame[i].Mirror ? 1f : 0f);
                    float ur = (info.SpriteFrame[i].Mirror ? 0f : 1f);

                    if (sizeless)                    //mxd
                    {
                        float hh = height / 2;
                        verts[0] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)(offsets.y - hh), sectorcolor, ul, 1.0f);
                        verts[1] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)(hh + offsets.y), sectorcolor, ul, 0.0f);
                        verts[2] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)(hh + offsets.y), sectorcolor, ur, 0.0f);
                        verts[3] = verts[0];
                        verts[4] = verts[2];
                        verts[5] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)(offsets.y - hh), sectorcolor, ur, 1.0f);
                    }
                    else
                    {
                        verts[0] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)offsets.y, sectorcolor, ul, 1.0f);
                        verts[1] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)(height + offsets.y), sectorcolor, ul, 0.0f);
                        verts[2] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)(height + offsets.y), sectorcolor, ur, 0.0f);
                        verts[3] = verts[0];
                        verts[4] = verts[2];
                        verts[5] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)offsets.y, sectorcolor, ur, 1.0f);
                    }
                    allverts[i] = verts;
                }
                else
                {
                    isloaded         = false;
                    base.textures[i] = sprite;

                    // Determine sprite size
                    float radius = Math.Min(thingradius, thingheight / 2f);
                    float height = Math.Min(thingradius * 2f, thingheight);

                    //mxd. Determine sprite offsets
                    offsets.x = radius;
                    offsets.y = height / 2;

                    // Make vertices
                    WorldVertex[] verts = new WorldVertex[6];
                    verts[0]    = new WorldVertex(-radius, 0.0f, 0.0f, sectorcolor, 0.0f, 1.0f);
                    verts[1]    = new WorldVertex(-radius, 0.0f, height, sectorcolor, 0.0f, 0.0f);
                    verts[2]    = new WorldVertex(+radius, 0.0f, height, sectorcolor, 1.0f, 0.0f);
                    verts[3]    = verts[0];
                    verts[4]    = verts[2];
                    verts[5]    = new WorldVertex(+radius, 0.0f, 0.0f, sectorcolor, 1.0f, 1.0f);
                    allverts[i] = verts;
                }

                //mxd. Store offsets
                alloffsets[i] = offsets;
            }

            //mxd
            SetVertices(allverts, alloffsets /*, floor, ceiling*/);

            // Determine position
            Vector3D pos = Thing.Position;

            if (Thing.Type == 9501)
            {
                if (Thing.Sector != null)                //mxd
                {
                    // This is a special thing that needs special positioning
                    SectorData sd = mode.GetSectorData(Thing.Sector);
                    pos.z = sd.Ceiling.sector.CeilHeight + Thing.Position.z;
                }
            }
            else if (Thing.Type == 9500)
            {
                if (Thing.Sector != null)                //mxd
                {
                    // This is a special thing that needs special positioning
                    SectorData sd = mode.GetSectorData(Thing.Sector);
                    pos.z = sd.Floor.sector.FloorHeight + Thing.Position.z;
                }
            }
            else if (info.AbsoluteZ)
            {
                // Absolute Z position
                pos.z = Thing.Position.z;
            }
            else if (info.Hangs)
            {
                // Hang from ceiling
                if (Thing.Sector != null)
                {
                    SectorData sd   = mode.GetSectorData(Thing.Sector);
                    double     maxz = sd.Ceiling.plane.GetZ(Thing.Position) - info.Height;
                    pos.z = maxz;

                    if (Thing.Position.z > 0 || nointeraction)
                    {
                        pos.z -= Thing.Position.z;
                    }

                    // Check if below floor
                    if (!nointeraction)
                    {
                        double minz = sd.Floor.plane.GetZ(Thing.Position);
                        if (pos.z < minz)
                        {
                            pos.z = Math.Min(minz, maxz);
                        }
                    }
                }
            }
            else
            {
                // Stand on floor
                if (Thing.Sector != null)
                {
                    SectorData sd   = mode.GetSectorData(Thing.Sector);
                    double     minz = sd.Floor.plane.GetZ(Thing.Position);
                    pos.z = minz;

                    if (Thing.Position.z > 0 || nointeraction)
                    {
                        pos.z += Thing.Position.z;
                    }

                    // Check if above ceiling
                    if (!nointeraction)
                    {
                        double maxz = sd.Ceiling.plane.GetZ(Thing.Position) - info.Height;
                        if (pos.z > maxz)
                        {
                            pos.z = Math.Max(minz, maxz);
                        }
                    }
                }
            }

            // Apply settings
            SetPosition(pos);
            SetCageColor(Thing.Color);

            // Keep info for object picking
            cageradius2 = thingradius * Angle2D.SQRT2;
            cageradius2 = cageradius2 * cageradius2;
            pos2d       = pos;

            if (sizeless)            //mxd
            {
                boxp1 = new Vector3D(pos.x - thingradius, pos.y - thingradius, pos.z - thingradius / 2);
                boxp2 = new Vector3D(pos.x + thingradius, pos.y + thingradius, pos.z + thingradius / 2);
            }
            else
            {
                boxp1 = new Vector3D(pos.x - thingradius, pos.y - thingradius, pos.z);
                boxp2 = new Vector3D(pos.x + thingradius, pos.y + thingradius, pos.z + thingheight);
            }

            // Done
            changed = false;
            return(true);
        }
예제 #39
0
        private static List <ImageData> ExtractType2_4(BinaryReader f, int numberOfImages, int type, List <Palette> extraPalettes = null)
        {
            var imgs = new List <ImageData>();

            short width  = f.ReadInt16();
            short height = f.ReadInt16();

            var compressedSizes = new List <int>();

            f.BaseStream.Seek(0x07, SeekOrigin.Begin);
            int pixelBlockOffset = 0x07 + numberOfImages * 4;
            int pixelBlockSize   = 0;

            for (int i = 0; i < numberOfImages; i++)
            {
                int compressedSize = (int)f.ReadUInt32();
                compressedSizes.Add(compressedSize);
                pixelBlockSize += compressedSize;
            }

            int paletteOffset = pixelBlockOffset + pixelBlockSize;

            f.BaseStream.Seek(paletteOffset, SeekOrigin.Begin);

            int numberOfColors = f.ReadInt16();
            var palette        = extraPalettes == null ? new Palette(f.ReadBytes(numberOfColors * 3), numberOfColors) : null;

            int offsetCompressedData = 0;

            for (int i = 0; i < numberOfImages; i++)
            {
                var img = new ImageData
                {
                    Width     = width,
                    Height    = height,
                    PixelData = new byte[width * height * 4]
                };

                int compressedSize = compressedSizes[i];

                // seek to image
                f.BaseStream.Seek(pixelBlockOffset + offsetCompressedData + (type == 0x02 ? 4 : 0), SeekOrigin.Begin);

                byte[] uncompressedData = new byte[width * height];
                byte[] compressedData   = f.ReadBytes(compressedSize - (type == 0x02 ? 4 : 0));

                // unpack
                if (type == 0x02)
                {
                    Native_UnpackPP20(compressedData, compressedData.Length, uncompressedData, uncompressedData.Length);
                }
                else if (type == 0x04)
                {
                    using var uncompressedStream = new MemoryStream(uncompressedData);
                    int offset = 0;

                    while (offset < compressedSize)
                    {
                        byte rle_data = compressedData[offset];
                        offset++;

                        if (rle_data == 0x7f)
                        {
                            int count = compressedData[offset];
                            offset++;
                            byte content = compressedData[offset];
                            offset++;

                            for (int j = 0; j < count; j++)
                            {
                                uncompressedStream.WriteByte(content);
                            }
                        }
                        else
                        {
                            uncompressedStream.WriteByte(rle_data);
                        }
                    }
                }

                using var ms = new MemoryStream(img.PixelData);

                // special handling of DUALPICS.NVF
                if (extraPalettes != null)
                {
                    palette = extraPalettes[i];
                }

                foreach (byte b in uncompressedData)
                {
                    ms.Write(palette.GetColor(b));
                }

                offsetCompressedData += compressedSize;

                imgs.Add(img);
            }

            return(imgs);
        }
예제 #40
0
        private static List <ImageData> ExtractType3_5(BinaryReader f, int numberOfImages, int type)
        {
            var imgs = new List <ImageData>();

            var resolutions     = new List <Tuple <int, int> >();
            var compressedSizes = new List <int>();

            f.BaseStream.Seek(0x03, SeekOrigin.Begin);
            int pixelBlockOffset = 0x03 + numberOfImages * 8;
            int pixelBlockSize   = 0;

            for (int i = 0; i < numberOfImages; i++)
            {
                int width          = f.ReadInt16();
                int height         = f.ReadInt16();
                int compressedSize = f.ReadInt32();

                resolutions.Add(new Tuple <int, int>(width, height));
                compressedSizes.Add(compressedSize);
                pixelBlockSize += compressedSize;
            }

            int paletteOffset = pixelBlockOffset + pixelBlockSize;

            f.BaseStream.Seek(paletteOffset, SeekOrigin.Begin);

            int numberOfColors = f.ReadInt16();
            var palette        = new Palette(f.ReadBytes(numberOfColors * 3), numberOfColors);

            int offsetCompressedData = 0;

            for (int i = 0; i < numberOfImages; i++)
            {
                var img = new ImageData
                {
                    Width     = resolutions[i].Item1,
                    Height    = resolutions[i].Item2,
                    PixelData = new byte[resolutions[i].Item1 * resolutions[i].Item2 * 4]
                };

                int compressedSize = compressedSizes[i];

                // seek to image
                f.BaseStream.Seek(pixelBlockOffset + offsetCompressedData + (type == 0x03 ? 4 : 0), SeekOrigin.Begin);

                byte[] uncompressedData = new byte[img.Width * img.Height];
                byte[] compressedData   = f.ReadBytes(compressedSize - (type == 0x03 ? 4 : 0));

                // unpack
                if (type == 0x03)
                {
                    Native_UnpackPP20(compressedData, compressedData.Length, uncompressedData, uncompressedData.Length);
                }
                else if (type == 0x05)
                {
                    using var uncompressedStream = new MemoryStream(uncompressedData);
                    int offset = 0;

                    while (offset < compressedSize)
                    {
                        byte rle_data = compressedData[offset];
                        offset++;

                        if (rle_data == 0x7f)
                        {
                            int count = compressedData[offset];
                            offset++;
                            byte content = compressedData[offset];
                            offset++;

                            for (int j = 0; j < count; j++)
                            {
                                uncompressedStream.WriteByte(content);
                            }
                        }
                        else
                        {
                            uncompressedStream.WriteByte(rle_data);
                        }
                    }
                }

                using var ms = new MemoryStream(img.PixelData);
                foreach (byte b in uncompressedData)
                {
                    ms.Write(palette.GetColor(b));
                }

                offsetCompressedData += compressedSize;

                imgs.Add(img);
            }

            return(imgs);
        }
예제 #41
0
 public string GetCelebrityInfo(ImageData imageData, byte[] imgData = null)
 {
     throw new NotImplementedException();
 }
예제 #42
0
 public override void Write(Stream file, ImageData image)
 {
     using (var output = new XoredStream(file, 0x21, true))
         using (var zstream = new ZLibStream(output, CompressionMode.Compress, CompressionLevel.Level9))
             base.Write(zstream, image);
 }
        // Blits a normal item
        void BlitItem(DaggerfallUnityItem item)
        {
            ImageData source = DaggerfallUnity.Instance.ItemHelper.GetItemImage(item, true, true);

            DrawTexture(source, item);
        }
예제 #44
0
        public ActionResult buildPDF(List <InformeResponse> lista, string nombreAsada)
        {
            MemoryStream ms = new MemoryStream();
            PdfWriter    pw = new PdfWriter(ms);

            PdfDocument pdfDocument = new PdfDocument(pw);
            Document    doc         = new Document(pdfDocument, PageSize.LETTER, false);

            doc.Add(new Paragraph("Reporte " + nombreAsada).SetFontSize(20).SetTextAlignment(TextAlignment.CENTER).SetFontColor(new DeviceRgb(4, 124, 188)));
            foreach (InformeResponse item in lista)
            {
                Preguntas preguntasObj = TipoFormulario(item.tipo);

                doc.Add(new Paragraph(item.acueducto).SetFontSize(15).SetBold());
                doc.Add(new Paragraph("Fecha: " + item.fecha).SetFontSize(12));
                doc.Add(new Paragraph("Encargado: " + item.encargado).SetFontSize(12).SetPaddingBottom(2));
                doc.Add(new Paragraph("Respuestas ").SetFontSize(12).SetUnderline());

                var infra = JsonConvert.DeserializeObject <Dictionary <string, string> >(item.infraestructura);
                foreach (var kv in infra)
                {
                    if (kv.Key == "P1")
                    {
                        doc.Add(new Paragraph(preguntasObj.p1 + ": " + kv.Value).SetFontSize(10));
                    }
                    else if (kv.Key == "P2")
                    {
                        doc.Add(new Paragraph(preguntasObj.p2 + ": " + kv.Value).SetFontSize(10));
                    }
                    else if (kv.Key == "P3")
                    {
                        doc.Add(new Paragraph(preguntasObj.p3 + ": " + kv.Value).SetFontSize(10));
                    }
                    else if (kv.Key == "P4")
                    {
                        doc.Add(new Paragraph(preguntasObj.p4 + ": " + kv.Value).SetFontSize(10));
                    }
                    else if (kv.Key == "P5")
                    {
                        doc.Add(new Paragraph(preguntasObj.p5 + ": " + kv.Value).SetFontSize(10));
                    }
                    else if (kv.Key == "P6")
                    {
                        doc.Add(new Paragraph(preguntasObj.p6 + ": " + kv.Value).SetFontSize(10));
                    }
                    else if (kv.Key == "P7")
                    {
                        doc.Add(new Paragraph(preguntasObj.p7 + ": " + kv.Value).SetFontSize(10));
                    }
                    else if (kv.Key == "P8")
                    {
                        doc.Add(new Paragraph(preguntasObj.p8 + ": " + kv.Value).SetFontSize(10));
                    }
                    else if (kv.Key == "P9")
                    {
                        doc.Add(new Paragraph(preguntasObj.p9 + ": " + kv.Value).SetFontSize(10));
                    }
                }
                doc.Add(new Paragraph("Comentarios: " + item.comentarios).SetFontSize(12));
                doc.Add(new Paragraph("Tipo de formulario: " + preguntasObj.tipo).SetFontSize(12));
                Cell cell = new Cell();
                cell.Add(new Paragraph("Riesgo " + item.riesgo).SetBorder(new SolidBorder(colorRiesgo(item.riesgo), 1)).SetBackgroundColor(colorRiesgo(item.riesgo)).SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER).SetFontSize(14).SetBold());
                doc.Add(cell);

                WebClient webClient = new WebClient();
                byte[]    data      = webClient.DownloadData(item.imagen);

                ImageData imageData = ImageDataFactory.Create(data);
                Image     image     = new Image(imageData);
                var       s         = 0.4;
                float     fwi       = (float)s;
                float     fhei      = (float)s;
                doc.Add(image.Scale(fwi, fhei).SetHorizontalAlignment(HorizontalAlignment.CENTER).SetMarginBottom(15).SetMarginTop(15));
            }
            //imagen del logo de sersa
            var       s2         = 0.08;
            float     fwi2       = (float)s2;
            float     fhei2      = (float)s2;
            WebClient webClient2 = new WebClient();

            byte[]    data2      = webClient2.DownloadData(logoletra);
            ImageData imageData2 = ImageDataFactory.Create(data2);
            Image     image2     = new Image(imageData2);
            Paragraph header     = new Paragraph("");

            header.Add(image2.Scale(fwi2, fhei2).SetMarginBottom(15));


            //imagen del logo de TEC
            var       s3         = 0.4;
            float     fwi3       = (float)s3;
            float     fhei3      = (float)s3;
            WebClient webClient3 = new WebClient();

            byte[]    data3      = webClient3.DownloadData(logotec);
            ImageData imageData3 = ImageDataFactory.Create(data3);
            Image     image3     = new Image(imageData3);
            Paragraph header2    = new Paragraph("");

            header2.Add(image3.Scale(fwi3, fhei3)).SetMarginBottom(10);



            for (int i = 1; i <= pdfDocument.GetNumberOfPages(); i++)
            {
                Rectangle pageSize = pdfDocument.GetPage(i).GetPageSize();
                float     x1       = 20;
                float     y1       = pageSize.GetTop() - 55;
                float     x2       = pageSize.GetRight() - 30;
                float     y2       = pageSize.GetTop() - 40;
                doc.ShowTextAligned(header, x1, y1, i, TextAlignment.LEFT, VerticalAlignment.BOTTOM, 0);
                doc.ShowTextAligned(header2, x2, y2, i, TextAlignment.RIGHT, VerticalAlignment.BOTTOM, 0);
            }



            doc.Close();

            byte[] bytesStream = ms.ToArray();
            ms = new MemoryStream();
            ms.Write(bytesStream, 0, bytesStream.Length);
            ms.Position = 0;

            return(new FileStreamResult(ms, "application/pdf"));
        }
예제 #45
0
 /// <summary>
 /// Creates an
 /// <see cref="Image"/>
 /// from an image resource, read in from a file
 /// with the iText I/O module, with a custom width and on a fixed position.
 /// </summary>
 /// <param name="img">
 /// an internal representation of the
 /// <see cref="iText.IO.Image.ImageData">image resource</see>
 /// </param>
 /// <param name="x">a float value representing the horizontal offset of the lower left corner of the image</param>
 /// <param name="y">a float value representing the vertical offset of the lower left corner of the image</param>
 /// <param name="width">a float value</param>
 public Image(ImageData img, float x, float y, float width)
     : this(new PdfImageXObject(CheckImageType(img)), x, y, width)
 {
     SetProperty(Property.FLUSH_ON_DRAW, true);
 }
예제 #46
0
        public static TerrainInfo CreateTerrainInfo(Terrain terrain, GraphBuilder.ExportSettings settings)
        {
            TerrainInfo terrainInfo         = new TerrainInfo();
            bool        usingCustomMaterial = false;

            if (terrain.materialType == Terrain.MaterialType.Custom)
            {
                // try and load a shader mapping file to match the custom terrain material
                terrainInfo.shaderMapping = ShaderMappingIO.ReadFromJsonFile(terrain.materialTemplate.shader);
                if (terrainInfo.shaderMapping != null)
                {
                    usingCustomMaterial = true;
                }
            }
            else
            {
                // load the default terrain shader mapping file
                terrainInfo.shaderMapping = ShaderMappingIO.ReadFromJsonFile(ShaderMappingIO.GetPathForShaderMappingFile("DefaultTerrain"));
            }

            if (terrainInfo.shaderMapping == null)
            {
                // no mapping loaded, use a default shader so we can at least export and render the terrain mesh
                NativeLog.WriteLine("GraphBuilder: Failed to load Terrain Shader Mapping file for terrain '" + terrain.name + "'.");
                terrainInfo.shaderMapping = ShaderMappingIO.ReadFromJsonFile(ShaderMappingIO.GetPathForShaderMappingFile("Default"));
                usingCustomMaterial       = true;
                return(null);
            }

            terrainInfo.shaderDefines.Add("VSG_LIGHTING");

            // build mesh
            int samplew = terrain.terrainData.heightmapWidth;
            int sampleh = terrain.terrainData.heightmapHeight;

            int cellw = terrain.terrainData.heightmapWidth - 1;
            int cellh = terrain.terrainData.heightmapHeight - 1;

            Vector3 size = terrain.terrainData.size;

            Vector2 cellsize   = new Vector3(size.x / cellw, size.z / cellh);
            Vector2 uvcellsize = new Vector2(1.0f / cellw, 1.0f / cellh);

            float[,] terrainHeights = terrain.terrainData.GetHeights(0, 0, samplew, sampleh);

            int vertcount = samplew * sampleh;

            Vector3[] verts   = new Vector3[vertcount];
            Vector3[] normals = new Vector3[vertcount];
            Vector2[] uvs     = new Vector2[vertcount];

            int[] indicies = new int[(cellw * cellh) * 6];

            // vertices and UVs
            for (int y = 0; y < samplew; y++)
            {
                for (int x = 0; x < sampleh; x++)
                {
                    verts[y * samplew + x].Set(x * cellsize.x, terrainHeights[y, x] * size.y, y * cellsize.y);
                    normals[y * samplew + x] = terrain.terrainData.GetInterpolatedNormal((float)x / (float)samplew, (float)y / (float)sampleh);
                    uvs[y * samplew + x].Set(x * uvcellsize.x, y * uvcellsize.y);
                }
            }

            CoordSytemConverter.Convert(verts);
            CoordSytemConverter.Convert(normals);

            // triangles
            int index = 0;

            for (int y = 0; y < cellw; y++)
            {
                for (int x = 0; x < cellh; x++)
                {
                    indicies[index++] = (y * samplew) + x;
                    indicies[index++] = ((y + 1) * samplew) + x;
                    indicies[index++] = (y * samplew) + x + 1;

                    indicies[index++] = ((y + 1) * samplew) + x;
                    indicies[index++] = ((y + 1) * samplew) + x + 1;
                    indicies[index++] = (y * samplew) + x + 1;
                }
            }

            CoordSytemConverter.FlipTriangleFaces(indicies);

            // convert to meshinfo
            MeshInfo mesh = null;

            if (!MeshConverter.GetMeshInfoFromCache(terrain.GetInstanceID(), out mesh))
            {
                mesh = new MeshInfo
                {
                    id               = terrain.GetInstanceID(),
                    verticies        = NativeUtils.WrapArray(verts),
                    normals          = NativeUtils.WrapArray(normals),
                    uv0              = NativeUtils.WrapArray(uvs),
                    triangles        = NativeUtils.WrapArray(indicies),
                    use32BitIndicies = 1
                };

                MeshConverter.AddMeshInfoToCache(mesh, terrain.GetInstanceID());
            }
            terrainInfo.terrainMesh = mesh;
            terrainInfo.terrainSize = size;

            // gather material info

            if (!usingCustomMaterial)
            {
                // use standard terrain layers
                TerrainLayer[] layers = terrain.terrainData.terrainLayers;
                for (int i = 0; i < layers.Length; i++)
                {
                    ImageData layerData = TextureConverter.GetOrCreateImageData(layers[i].diffuseTexture);
                    terrainInfo.diffuseTextureDatas.Add(layerData);

                    terrainInfo.diffuseScales.Add(new Vector4(1.0f / layers[i].tileSize.x, 1.0f / layers[i].tileSize.y));
                }

                for (int i = 0; i < terrain.terrainData.alphamapTextureCount; i++)
                {
                    Texture2D srcmask   = terrain.terrainData.GetAlphamapTexture(i);
                    ImageData splatData = TextureConverter.GetOrCreateImageData(srcmask);

                    terrainInfo.maskTextureDatas.Add(splatData);
                }

                if (terrainInfo.diffuseTextureDatas.Count > 0)
                {
                    terrainInfo.descriptorBindings.Add(new VkDescriptorSetLayoutBinding()
                    {
                        binding = 0, descriptorType = VkDescriptorType.VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, stageFlags = VkShaderStageFlagBits.VK_SHADER_STAGE_FRAGMENT_BIT, descriptorCount = (uint)terrainInfo.diffuseTextureDatas.Count
                    });
                    terrainInfo.descriptorBindings.Add(new VkDescriptorSetLayoutBinding()
                    {
                        binding = 2, descriptorType = VkDescriptorType.VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, stageFlags = VkShaderStageFlagBits.VK_SHADER_STAGE_FRAGMENT_BIT, descriptorCount = (uint)terrainInfo.diffuseScales.Count
                    });

                    terrainInfo.shaderConsts.Add(terrainInfo.diffuseTextureDatas.Count);
                    terrainInfo.shaderDefines.Add("VSG_TERRAIN_LAYERS");
                }

                terrainInfo.descriptorBindings.Add(new VkDescriptorSetLayoutBinding()
                {
                    binding = 3, descriptorType = VkDescriptorType.VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, stageFlags = VkShaderStageFlagBits.VK_SHADER_STAGE_FRAGMENT_BIT, descriptorCount = 1
                });

                if (terrainInfo.maskTextureDatas.Count > 0)
                {
                    terrainInfo.descriptorBindings.Add(new VkDescriptorSetLayoutBinding()
                    {
                        binding = 1, descriptorType = VkDescriptorType.VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, stageFlags = VkShaderStageFlagBits.VK_SHADER_STAGE_FRAGMENT_BIT, descriptorCount = (uint)terrainInfo.maskTextureDatas.Count
                    });
                    terrainInfo.shaderConsts.Add(terrainInfo.maskTextureDatas.Count);
                }
            }
            else
            {
                Material customMaterial = terrain.materialTemplate;
                terrainInfo.customMaterial = MaterialConverter.CreateMaterialData(customMaterial, terrainInfo.shaderMapping);
                terrainInfo.customMaterial.customDefines = terrainInfo.shaderDefines;
            }

            return(terrainInfo);
        }
예제 #47
0
 public RecognitionConfiguration(string filePath)
 {
     Engine        = new EngineConfiguration();
     Image         = new ImageData(filePath);
     Preprocessors = Enumerable.Repeat(new PreprocessorConfiguration(), 1).ToArray();
 }
예제 #48
0
        private ImageData load_image(Image img)
        {
            int width  = img.Width;
            int height = img.Height;

            int targetWidth = 480, targetHeight = 640;
            int wRatio = 1, hRatio = 1;

            if (width > targetWidth)
            {
                wRatio = width / targetWidth;
            }

            if (height > targetHeight)
            {
                hRatio = height / targetHeight;
            }

            if (wRatio > 1 || hRatio > 1)
            {
                if (wRatio > hRatio)
                {
                    width  = targetWidth;
                    height = ((height / wRatio) >> 2) << 2;
                    img    = resizeImage(img, new Size(width, height));
                }
                else
                {
                    width  = ((width / hRatio) >> 2) << 2;
                    height = targetHeight;
                    img    = resizeImage(img, new Size(width, height));
                }
            }

            ImageData imageData = new ImageData();

            imageData.Width  = width;
            imageData.Height = height;

            byte[] result;
            using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
            {
                img.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);   // convert png to bmp
                result = stream.GetBuffer();
            }

            byte[] image = new byte[width * height * 4];

            int offset      = 54;
            int iIndex      = 0;
            int iRowIndex   = 0;
            int iPixelBytes = 4;

            if (img.PixelFormat == System.Drawing.Imaging.PixelFormat.Format24bppRgb)
            {
                iPixelBytes = 3;
            }

            int iWidth = width * iPixelBytes;

            for (int i = height - 1; i >= 0; --i)
            {
                iRowIndex = i * iWidth;
                for (int j = 0; j < iWidth; j += iPixelBytes)
                {
                    if (iPixelBytes == 3)
                    {
                        image[iIndex++] = result[iRowIndex + j + 2 + offset]; // B
                        image[iIndex++] = result[iRowIndex + j + 1 + offset]; // G
                        image[iIndex++] = result[iRowIndex + j + offset];     // R
                        image[iIndex++] = 255;                                // A
                    }
                    else
                    {
                        image[iIndex++] = result[iRowIndex + j + 2 + offset]; // B
                        image[iIndex++] = result[iRowIndex + j + 1 + offset]; // G
                        image[iIndex++] = result[iRowIndex + j + offset];     // R
                        image[iIndex++] = result[iRowIndex + j + 3 + offset]; // A
                    }
                }
            }

            imageData.Data = image;

            return(imageData);
        }
예제 #49
0
 private void testphoto(ImageData ImgData)
 {
 }
예제 #50
0
 public static extern int ExtractFeature(IntPtr engine, ref ImageData imageData, ref FaceFeatureInput faceFeatureInput, out FaceModel faceModel);