Esempio n. 1
0
        private void FlushCanvases(Action <byte[]> onChunkReady)
        {
            for (int y = 0; y < Height; y += TileHeight)
            {
                RCINFO[] rcs = new RCINFO[WidthCount];
                int      i   = 0;
                for (int x = 0; x < Width; x += TileWidth)
                {
                    var canvas = GetCanvas(x, y);
                    var rcinfo = new RCINFO
                    {
                        currentOffset = 0,
                        rc            = canvas,
                    };

                    canvas.LockAddress(out rcinfo.pitch, out rcinfo.data);
                    rcinfo.length = Math.Min(Width - x, TileWidth) * canvas.PixFormat.BytesPerPixel();
                }

                var tileHeightSize = TileSize(Math.Min(TileHeight, Height - y));
                var bytesPerWrite  = PixFormat.PixelsPerYAxis();
                // We need to correct for DXT3/DXT5 images having multiple pixels in Y axis per written bytes
                // Additionally, MagLevel also applies to the canvases, so need to keep that
            }
        }
Esempio n. 2
0
        public static void CodePixFormat(this ICoder coder, ref PixFormat pixFormat)
        {
            var    reading    = coder.IsReading;
            Type   type       = reading ? null : pixFormat.Type;
            string formatName = reading ? null : pixFormat.Format.GetName().ToString();

            coder.CodeType(ref type);
            coder.CodeString(ref formatName);
            if (reading)
            {
                pixFormat = new PixFormat(type, Col.FormatOfName(formatName));
            }
        }
Esempio n. 3
0
        protected static PixImage CreateRaw(FormatConvertedBitmap fcBitmap, PixFormat pixFormat, int channels)
        {
            var sx = fcBitmap.PixelWidth;
            var sy = fcBitmap.PixelHeight;

            if (pixFormat.Format == Col.Format.BW)
            {
                var bitImage = new PixImage <byte>(Col.Format.BW, 1 + (sx - 1) / 8, sy, channels);
                fcBitmap.CopyPixels(bitImage.Array, bitImage.IntStride, 0);
                var pixImage = new PixImage <byte>(Col.Format.BW, sx, sy, 1);
                ExpandPixels(bitImage, pixImage);
                return(pixImage);
            }
            else
            {
                var pixImage = Create(pixFormat, sx, sy, channels);
                fcBitmap.CopyPixels(pixImage.Array, pixImage.IntStride, 0);
                return(pixImage);
            }
        }
        public static List<string> PointGenerator(string inputBitmapPath, PixFormat _pixFor)
        {
            List<string> imglist = new List<string>();
            try
            {
                if (_pixFor == PixFormat._null)
                    throw new Exception("Format null olamaz") { Source = "" };

                using (MagickImage imagem = new MagickImage(inputBitmapPath))
                {
                    //############# ResizeImage #############
                    int yuzde = 100;
                    imagem.Quality = 100;
                    int _w = imagem.Width + (imagem.Width / 100) * yuzde;
                    int _h = imagem.Height + (imagem.Height / 100) * yuzde;
                    int new_W = _w - (_w % (int)_pixFor);
                    int new_H = _h - (_h % (int)_pixFor);
                    imagem.Resize(new_W, new_H);
                    imagem.Blur(5, 5);
                    //############# GenerateSquare #############
                    /////////// calculate image point rgb avg   ////////////
                    string curImgPth = Path.GetFileName(inputBitmapPath);
                    string path = UserProperty.PixelXmlMap_Path + "\\" + curImgPth.Substring(0, curImgPth.Length - 4) + _pixFor.ToString() + "_.xml";
                    FileInfo finf = new FileInfo(path);
                    List<ImgSquare> sp0 = new List<ImgSquare>();
                    if (!File.Exists(path))
                    {
                        int[,] pixavg = new int[5, 3];
                        int _pixformat = (int)_pixFor;
                        WritablePixelCollection _totalpix = imagem.GetWritablePixels(0, 0, imagem.Width, imagem.Height);
                        int range = _pixformat / 2;
                        for (int w = 0; w < imagem.Width; w += _pixformat)
                        {
                            for (int h = 0; h < imagem.Height; h += _pixformat)
                            {
                                if (!(w + _pixformat <= imagem.Width && h + _pixformat <= imagem.Height))
                                    continue;//olmazda olursa diye
                                pixavg = new int[5, 3];
                                for (int x = 0; x < range; x++)
                                {
                                    for (int y = 0; y < range; y++)
                                    {
                                        Color a = _totalpix.GetPixel(x + w + 0, h + 0 + y).ToColor().ToColor();
                                        pixavg[0, 0] += a.R;
                                        pixavg[0, 1] += a.G;
                                        pixavg[0, 2] += a.B;

                                        Color b = _totalpix.GetPixel(x + w + range, h + y).ToColor().ToColor();
                                        pixavg[1, 0] += b.R;
                                        pixavg[1, 1] += b.G;
                                        pixavg[1, 2] += b.B;

                                        Color c = _totalpix.GetPixel(x + w, h + range + y).ToColor().ToColor();
                                        pixavg[2, 0] += c.R;
                                        pixavg[2, 1] += c.G;
                                        pixavg[2, 2] += c.B;

                                        Color d = _totalpix.GetPixel(x + w + range, h + range + y).ToColor().ToColor();
                                        pixavg[3, 0] += d.R;
                                        pixavg[3, 1] += d.G;
                                        pixavg[3, 2] += d.B;
                                    }
                                }

                                //tümü için aynı toplanıyor
                                pixavg[4, 0] = pixavg[0, 0] + pixavg[1, 0] + pixavg[2, 0] + pixavg[3, 0];
                                pixavg[4, 1] = pixavg[0, 1] + pixavg[1, 1] + pixavg[2, 1] + pixavg[3, 1];
                                pixavg[4, 2] = pixavg[0, 2] + pixavg[1, 2] + pixavg[2, 2] + pixavg[3, 2];
                                //----

                                int totalminiPix = (range * range);
                                pixavg[0, 0] /= totalminiPix;
                                pixavg[0, 1] /= totalminiPix;
                                pixavg[0, 2] /= totalminiPix;

                                pixavg[1, 0] /= totalminiPix;
                                pixavg[1, 1] /= totalminiPix;
                                pixavg[1, 2] /= totalminiPix;

                                pixavg[2, 0] /= totalminiPix;
                                pixavg[2, 1] /= totalminiPix;
                                pixavg[2, 2] /= totalminiPix;

                                pixavg[3, 0] /= totalminiPix;
                                pixavg[3, 1] /= totalminiPix;
                                pixavg[3, 2] /= totalminiPix;


                                int totalPix = totalminiPix * 4;
                                pixavg[4, 0] /= totalPix;
                                pixavg[4, 1] /= totalPix;
                                pixavg[4, 2] /= totalPix;

                                sp0.Add(new ImgSquare(w, h, new List<QuardPixAvg>() 
                            {
                                new QuardPixAvg(Color.FromArgb((pixavg[0, 0]), (pixavg[0, 1]), (pixavg[0, 2])), QuardBolum.SolUst),
                                new QuardPixAvg (Color.FromArgb((pixavg[1, 0]), (pixavg[1, 1]), (pixavg[1, 2])), QuardBolum.SagUst),
                                new QuardPixAvg(Color.FromArgb((pixavg[2, 0]), (pixavg[2, 1]), (pixavg[2, 2])), QuardBolum.SolAlt),
                                new QuardPixAvg(Color.FromArgb((pixavg[3, 0]), (pixavg[3, 1]), (pixavg[3, 2])), QuardBolum.SagAlt),
                                new QuardPixAvg(Color.FromArgb((pixavg[4, 0]), (pixavg[4, 1]), (pixavg[4, 2])), QuardBolum.TotalAvg)
                            }));
                            }
                        }
                        _totalpix = null;
                        pixavg = null;
                        ////////////////////////////// xml generate ///////////////////////////////
                        #region xml oluşturma
                        //XmlDocument doc = new XmlDocument();
                        //XmlElement root = doc.CreateElement("SquarePoints");
                        //root.SetAttribute("Count", sp0.Count.ToString());
                        //root.SetAttribute("PixFormat", _pixFor.ToString());
                        //foreach (ImgSquare item in sp0)
                        //{
                        //    XmlElement child = doc.CreateElement("SquarePoint");
                        //    child.SetAttribute("WxH", item.ToString());
                        //    child.SetAttribute("ColorAVG", item.SAvgArb.ToString());
                        //    List<QuardPixAvg> lstQ = item.QuardAvg;
                        //    child.SetAttribute("SolUst", lstQ[0].QuardAvg.ToString());
                        //    child.SetAttribute("SagUst", lstQ[1].QuardAvg.ToString());
                        //    child.SetAttribute("SolAlt", lstQ[2].QuardAvg.ToString());
                        //    child.SetAttribute("SagAlt", lstQ[3].QuardAvg.ToString());
                        //    root.AppendChild(child);
                        //}
                        //doc.AppendChild(root);
                        //if (!Directory.Exists(finf.Directory.FullName))
                        //    Directory.CreateDirectory(finf.Directory.FullName);
                        //doc.Save(path);
                        //doc = null;
                        #endregion
                    }
                    else
                    {
                        #region xml okuma
                        //XmlDocument doc = new XmlDocument();
                        //doc.Load(path);
                        //XmlNodeList root1 = doc.GetElementsByTagName("SquarePoints");
                        //XmlNode root2 = root1.Item(0);
                        //foreach (XmlNode item in root2.ChildNodes)
                        //{
                        //    try
                        //    {
                        //        XmlAttribute at1 = item.Attributes[0];
                        //        string[] point = at1.InnerText.Split('x');
                        //        XmlAttribute at2 = item.Attributes[1];
                        //        string ColorAvg = at2.InnerText;
                        //        List<QuardPixAvg> lQuard = new List<QuardPixAvg>();
                        //        int SolUst = int.Parse(item.Attributes[2].InnerText);
                        //        int SagUst = int.Parse(item.Attributes[3].InnerText);
                        //        int SolAlt = int.Parse(item.Attributes[4].InnerText);
                        //        int SagAlt = int.Parse(item.Attributes[5].InnerText);
                        //        int Tumu = int.Parse(item.Attributes[1].InnerText);
                        //        lQuard.Add(new QuardPixAvg(Color.FromArgb(SolUst), QuardBolum.SolUst));
                        //        lQuard.Add(new QuardPixAvg(Color.FromArgb(SagUst), QuardBolum.SagUst));
                        //        lQuard.Add(new QuardPixAvg(Color.FromArgb(SolAlt), QuardBolum.SolAlt));
                        //        lQuard.Add(new QuardPixAvg(Color.FromArgb(SagAlt), QuardBolum.SagAlt));
                        //        lQuard.Add(new QuardPixAvg(Color.FromArgb(Tumu), QuardBolum.Tumu));
                        //        sp0.Add(new ImgSquare(int.Parse(point[0]), int.Parse(point[1]), lQuard));
                        //    }
                        //    catch (Exception e)
                        //    {
                        //        throw e;
                        //    }
                        //}
                        //root2 = null;
                        //root1 = null;
                        //doc = null;
                        #endregion
                    }
                    //#---------------------------------
                    int opacity = 50;
                    switch (_pixFor)
                    {
                        case PixFormat._null:
                            sp0.Clear();
                            throw new Exception("Tanımsız format") { Source = "" };
                            break;
                        case PixFormat._12x12: //12:36 sn
                            opacity = 50;
                            break;
                        case PixFormat._20x20: //3:10 sn
                            opacity = 50;
                            break;
                        case PixFormat._36x36: //0:50 sn
                            opacity = 50;
                            break;
                        case PixFormat._48x48: //0:27 sn
                            opacity = 50;
                            break;
                        case PixFormat._64x64: //0:15 sn
                            opacity = 50;
                            break;
                        case PixFormat._94x94: //0:08 sn
                            opacity = 50;
                            break;
                    }
                    //string MiniPicturePath = Path.Combine(UserProperty.Data_Path, PixFormat._94x94.ToString());  //eski yükleme şekli
                    string MiniPicturePath = Path.Combine(UserProperty.Data_InstagramPhotos);
                    if (Directory.Exists(MiniPicturePath))
                    {
                        Bitmap btm = imagem.ToBitmap();
                        using (Graphics gr1 = Graphics.FromImage(btm))
                        {
                            //string[] list = Directory.GetFiles(MiniPicturePath, "*" + JPG);
                            //string[] list = new string[0];
                            ///////////////////////////////////////////////////////////////
                            string[] file = Directory.GetFiles(UserProperty.Current_User, UserProperty.UserXmlInfo);

                            if (file.Count() != 1)
                                throw new Exception("Geçersiz kullanıcı bilgileri");

                            XDocument doc = XDocument.Load(file[0]);
                            XElement root = doc.Elements("_" + ImageProperty.GetUserName()).First();
                            XElement InstagramP = root.Elements("InstagramPhotos").FirstOrDefault();
                            XElement[] photos = (from p in InstagramP.Elements() where p.Attribute("useThis").Value.ToLower() == "true" select p).ToArray();
                            //list = new string[photos.Count()];

                            //for (int i = 0; i < photos.Count(); i++)
                            //    list[i] = Path.Combine(MiniPicturePath, photos[i].Value);

                            ///////////////////////////////////////////////////
                            if (photos.Count() == 0)
                                throw new Exception("Bu Formata Uygun Resimler Bulunamadı") { Source = "" };

                            List<ImgSquare> spl2 = new List<ImgSquare>();
                            for (int i = 0; i < photos.Count(); i++)
                            {
                                if (File.Exists(Path.Combine(MiniPicturePath, Path.GetFileName(photos[i].Value))))
                                {
                                    using (MagickImage mini = new MagickImage(Path.Combine(MiniPicturePath, Path.GetFileName(photos[i].Value))))
                                    {
                                        mini.Quality = 100;
                                        if (mini.Width != 94 && mini.Height != 94)
                                            mini.Resize((int)_pixFor, (int)_pixFor);

                                        //ImgSquare imgsq = new ImgSquare(mini.ToBitmap(), new List<QuardPixAvg>() { 
                                        //    new QuardPixAvg(Color.FromArgb(int.Parse(photos[i].Attribute("SolUst").Value)),QuardBolum.SagAlt),
                                        //    new QuardPixAvg(Color.FromArgb(int.Parse(photos[i].Attribute("SagUst").Value)),QuardBolum.SagAlt),
                                        //    new QuardPixAvg(Color.FromArgb(int.Parse(photos[i].Attribute("SolAlt").Value)),QuardBolum.SagAlt),
                                        //    new QuardPixAvg(Color.FromArgb(int.Parse(photos[i].Attribute("SagAlt").Value)),QuardBolum.SagAlt),
                                        //    new QuardPixAvg(Color.FromArgb(int.Parse(photos[i].Attribute("TotalAvg").Value)),QuardBolum.SagAlt)
                                        //});
                                        spl2.Add(new ImgSquare(mini.ToBitmap()));
                                        mini.Dispose();
                                    }
                                }
                            }
                            photos = null;
                            doc = null;
                            root = null;
                            InstagramP = null;
                            List<ImgSquare> spl4 = new List<ImgSquare>();
                            spl4.AddRange(sp0);
                            spl4.AddRange(spl2);
                            spl2.Clear();
                            spl4 = spl4.OrderBy(p => p.GeneratedColorCode).ToList();
                            int qpiro_number = 432101;
                            int qpiro_number2 = 0;
                            int undefined = 0;
                            for (int i = 0; i < sp0.Count; i++)
                            {
                                ImgSquare item = sp0[i];
                                //if (item.SAvgArb == 0 && item.IAvgRgb == 0)
                                //    continue;
                                try
                                {
                                    qpiro_number2 = 0;
                                    List<ImgSquare> snc = null;
                                    int cont = 0;
                                    do
                                    {
                                        snc = spl4.Where(p =>
                                            (p.GeneratedColorCode - (qpiro_number + qpiro_number2) < item.GeneratedColorCode &&
                                            p.GeneratedColorCode + (qpiro_number + qpiro_number2) > item.GeneratedColorCode) &&
                                            p.isArea == false).ToList();
                                        qpiro_number2 += 332101;
                                        cont++;
                                    }
                                    while (snc.Count == 0 && cont < 5);

                                    Rectangle rec = new Rectangle(item.W, item.H, (int)_pixFor, (int)_pixFor);

                                    if (snc.Count != 0)
                                    {
                                        int randi = random.Next(0, snc.Count);
                                        System.Drawing.Image img = SmartRotate(item, snc[randi]);
                                        snc.Clear();// 
                                        img = Transparnt(img, opacity);
                                        gr1.DrawImage(img, rec);
                                        sp0.RemoveAt(i);
                                        i--;
                                        img.Dispose();
                                    }
                                    else
                                    {
                                        using (MagickImage imgUndefined = new MagickImage(Path.Combine(UserProperty.Data_InstagramPhotos, "black.jpg")))
                                        {
                                            System.Drawing.Image img = Transparnt(imgUndefined.ToBitmap(), opacity);
                                            gr1.DrawImage(img, rec);
                                            sp0.RemoveAt(i);
                                            i--;
                                            imgUndefined.Dispose();
                                        }
                                        //int ss = item.GeneratedColorCode;
                                        //if (ss >= 11075440 && ss <= 15260100)
                                        //{
                                        //    cont = 0;
                                        // qpiro_number2 += 332101;
                                        //    do
                                        //    {
                                        //        snc = spl4.Where(p =>
                                        //            (p.GeneratedColorCode - (qpiro_number + qpiro_number2) < item.GeneratedColorCode &&
                                        //            p.GeneratedColorCode + (qpiro_number + qpiro_number2) > item.GeneratedColorCode) &&
                                        //            p.isArea == false).ToList();
                                        //        qpiro_number2 += 332101;
                                        //        cont++;
                                        //    }
                                        //    while (snc.Count == 0 && cont < 13);

                                        //    if (snc.Count != 0)
                                        //    {
                                        //        Rectangle rec = new Rectangle(item.W, item.H, (int)_pixFor, (int)_pixFor);
                                        //        int randi = random.Next(0, snc.Count);
                                        //        System.Drawing.Image img = SmartRotate(item, snc[randi]);
                                        //        snc.Clear();// 
                                        //        img = Transparnt(img, opacity);
                                        //        gr1.DrawImage(img, rec);
                                        //        sp0.RemoveAt(i);
                                        //        i--;
                                        //    }
                                        //    else
                                        //    {

                                        //    }
                                        //}
                                        undefined++;
                                    }
                                }
                                catch (Exception ef)
                                {
                                    throw ef;
                                }
                            }
                            sp0.Clear();
                            spl4.Clear();
                            gr1.Dispose();
                            //workingBitmap1.Save(Path.Combine(UsrImageProc.SavedPhotos_Path, Path.GetFileName(inputBitmapPath)));
                            //imglist.Add("lokale kaydettim");
                            Bitmap hd = btm.ArithmeticBlend(btm, ColorCalculationType.Add);
                            imglist.Add(ImageToBase64(hd, System.Drawing.Imaging.ImageFormat.Jpeg));
                            imglist.Add(ImageToBase64(btm, System.Drawing.Imaging.ImageFormat.Jpeg));
                            btm.Dispose();
                            hd.Dispose();
                            imagem.Dispose();
                        }
                    }
                    else
                    {
                        throw new Exception("Bu Formata Uygun Resimler Bulunamadı2") { Source = "" };
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return imglist;
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the color for pixel format.
        /// </summary>
        /// <param name="PixelFormat">The tex reader.</param>
        /// <param name="Stream">The tex pixel format.</param>
        public static Color GetColor(BinaryReader Stream, int PixelFormat)
        {
            PixFormat Format = (PixFormat)PixelFormat;

            switch (Format)
            {
            case PixFormat.RGBA_8888:
            case PixFormat.RGBA_8888b:
            {
                byte ColorR = Stream.ReadByte();
                byte ColorG = Stream.ReadByte();
                byte ColorB = Stream.ReadByte();
                byte ColorA = Stream.ReadByte();

                return(Color.FromArgb((ColorA << 24) | (ColorR << 16) | (ColorG << 8) | ColorB));
            }

            case PixFormat.RGBA_4444:
            {
                ushort RColor = Stream.ReadUInt16();

                int ColorR = ((RColor >> 12) & 0xF) << 4;
                int ColorG = ((RColor >> 8) & 0xF) << 4;
                int ColorB = ((RColor >> 4) & 0xF) << 4;
                int ColorA = (RColor & 0xF) << 4;

                return(Color.FromArgb(ColorA, ColorR, ColorG, ColorB));
            }

            case PixFormat.RGB_565:
            {
                ushort _Color = Stream.ReadUInt16();

                int Red   = ((_Color >> 11) & 0x1F) << 3;
                int Green = ((_Color >> 5) & 0x3F) << 2;
                int Blue  = ((_Color & 0X1F) << 0x03);

                return(Color.FromArgb(Red, Green, Blue));
            }

            case PixFormat.LUMINANCE8_A8:
            {
                ushort _Color = Stream.ReadUInt16();

                int Alpha = _Color & 0xFF;
                int RGB   = _Color >> 8;

                int Red   = RGB;
                int Green = RGB;
                int Blue  = RGB;

                return(Color.FromArgb(Alpha, Red, Green, Blue));
            }

            case PixFormat.LUMINANCE8:
            {
                ushort _Color = Stream.ReadByte();

                int Red   = _Color;
                int Green = _Color;
                int Blue  = _Color;

                return(Color.FromArgb(Red, Green, Blue));
            }

            default:
            {
                Logging.Error(typeof(PixHelper), "Pixel Format n°" + PixelFormat + " is not supported.");
            }

            break;
            }

            return(Color.Empty);
        }
        public IHttpActionResult ImageGenerate()
        {
            QpiroJSON resp = new QpiroJSON();
            UserProperty.ImgType itype = new UserProperty.ImgType();
            PixFormat PixelFormat = new PixFormat();
            string imgName = "";
            try
            {
                ///////////////////////////////////////////////
                int bsy = UserProperty.XmlGetValue("Busy");
                if (bsy == 1)
                    throw new Exception("Bir işlem halen devam etmekte bitmesini bekleyiniz.") { Source = "Busy" };
                ///////////////////////////////////////////////////
                int tck = UserProperty.XmlGetValue("Ticket");
                if (tck == -3)
                {
                    throw new Exception("Kullanıcı bilgileri bulunamadı.") { Source = "Ticket1" };
                }
                else
                {
                    if (!UserProperty.EmailVerified)
                        throw new Exception("Eposta adresinizi onaylamanız gerekmektedir") { Source = "EVerified" };

                    if (-1 >= tck - 1)
                    {
                        throw new Exception("Biletiniz bitmiş işlem yapamıyoruz.") { Source = "Ticket2" };
                    }
                    else
                    {
                        UserProperty.XmlUpdate("Ticket", -1, true);
                        UserProperty.XmlUpdate("Busy", 1, false);
                    }
                }
                ////////////////////////////////////////////////////
                imgName = Convert.ToString(HttpContext.Current.Request["imagename"]);
                itype = UserProperty.ImgType.Resources;
                string typ = HttpContext.Current.Request["pixtype"];
                if (typ == null)
                    throw new Exception("Lütfen format seçiniz") { Source = "" };

                PixelFormat = (PixFormat)ImageProperty.StringToEnum(typeof(PixFormat), Convert.ToString(typ));
            }
            catch (Exception e)
            {
                if (e.Source == "Ticket1" ||
                    e.Source == "Ticket2" ||
                    e.Source == "Ticket3" ||
                    e.Source == "Ticket4" ||
                    e.Source == "Busy" ||
                    e.Source == "EVerified")
                { }
                else
                {
                    UserProperty.XmlUpdate("Ticket", 1, true);
                    UserProperty.XmlUpdate("Busy", 0, false);
                }
                resp.Message = e.Message;
                return this.Json<QpiroJSON>(resp);
            }
            try
            {
                string imgPath = "";
                switch (itype)
                {
                    case UserProperty.ImgType.Resources:
                        imgPath = Path.Combine(UserProperty.ResourcePhotos_Path, imgName + ImageProperty.JPG);
                        break;

                    default:
                        throw new Exception("Tanımlanamayan imagename formatı") { Source = "" };
                        break;
                }
                if (File.Exists(imgPath))
                {
                    DateTime start = DateTime.Now;
                    System.GC.Collect();
                    List<PartOfImage> imgsInf = ImageProperty.PartOfImage(imgPath, imgName, (int)PixelFormat);
                    ServerAsyncCallBack servers = new ServerAsyncCallBack();
                    servers.Execute(_QPR.Type.AsyncCallType.ImageGenerate, imgsInf, (int)PixelFormat);
                    imgsInf.Clear();
                    if (UserProperty.ComputerNumber == 1)
                    {
                        do
                        {
                            Thread.Sleep(999);
                        } while (servers._respLocalTest.Status == TaskStatus.WaitingForActivation);

                    }
                    else
                    {
                        do
                        {
                            Thread.Sleep(999);
                        } while (
                        servers._resp1.Status == TaskStatus.WaitingForActivation ||
                        servers._resp2.Status == TaskStatus.WaitingForActivation ||
                        servers._resp3.Status == TaskStatus.WaitingForActivation ||
                        servers._resp4.Status == TaskStatus.WaitingForActivation ||
                        servers._resp5.Status == TaskStatus.WaitingForActivation ||
                        servers._resp6.Status == TaskStatus.WaitingForActivation ||
                        servers._resp7.Status == TaskStatus.WaitingForActivation ||
                        servers._resp8.Status == TaskStatus.WaitingForActivation
                        );
                    }
                    DateTime end = DateTime.Now;
                    string time = TimeSpan.FromTicks(end.Ticks - start.Ticks).ToString();
                    resp.Time = (time.Split(':')[time.Split(':').Length - 2] + ":" + time.Split(':')[time.Split(':').Length - 1]);
                    ///////////////////////////////////////
                    if (UserProperty.ComputerNumber == 1)//local test
                    {
                        byte[] bitmp0 = servers._respLocalTest.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br0 = ImageProperty.stringToRectangle(servers._respLocalTest.Result.Body.ImageGenerateResult.ImagePartInfo);
                        MagickImage img0 = new MagickImage(bitmp0);
                        Bitmap newImg0 = new Bitmap(img0.Width, img0.Height);
                        Graphics grr0 = Graphics.FromImage(newImg0);
                        grr0.DrawImage(img0.ToBitmap(), br0.X, br0.Y);
                        grr0.Dispose();
                        (resp.Data as List<object>).Add(ImageProperty.ImageToBase64(newImg0, System.Drawing.Imaging.ImageFormat.Jpeg));
                    }
                    else
                    {
                        byte[] bitmp1 = servers._resp1.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br1 = ImageProperty.stringToRectangle(servers._resp1.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp2 = servers._resp2.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br2 = ImageProperty.stringToRectangle(servers._resp2.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp3 = servers._resp3.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br3 = ImageProperty.stringToRectangle(servers._resp3.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp4 = servers._resp4.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br4 = ImageProperty.stringToRectangle(servers._resp4.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp5 = servers._resp5.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br5 = ImageProperty.stringToRectangle(servers._resp5.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp6 = servers._resp6.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br6 = ImageProperty.stringToRectangle(servers._resp6.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp7 = servers._resp7.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br7 = ImageProperty.stringToRectangle(servers._resp7.Result.Body.ImageGenerateResult.ImagePartInfo);
                        byte[] bitmp8 = servers._resp8.Result.Body.ImageGenerateResult.newImage;
                        Rectangle br8 = ImageProperty.stringToRectangle(servers._resp8.Result.Body.ImageGenerateResult.ImagePartInfo);

                        servers = null;
                        int newW = 0, newH = 0;
                        if (br1.Width < br1.Height)
                        {
                            newW = br1.Width * UserProperty.ComputerNumber;
                            newH = br1.Height;
                        }
                        else
                        {
                            newW = br1.Width;
                            newH = br1.Height * UserProperty.ComputerNumber;
                        }
                        //MagickImage img0 = new MagickImage(bitmp0);

                        MagickImage img1 = new MagickImage(bitmp1);
                        MagickImage img2 = new MagickImage(bitmp2);
                        MagickImage img3 = new MagickImage(bitmp3);
                        MagickImage img4 = new MagickImage(bitmp4);
                        MagickImage img5 = new MagickImage(bitmp5);
                        MagickImage img6 = new MagickImage(bitmp6);
                        MagickImage img7 = new MagickImage(bitmp7);
                        MagickImage img8 = new MagickImage(bitmp8);

                        Bitmap newImg = new Bitmap(newW, newH);
                        Graphics grr = Graphics.FromImage(newImg);
                        //grr.DrawImage(img0.ToBitmap(), br0.X, br0.Y);
                        grr.DrawImage(img1.ToBitmap(), br1.X, br1.Y);
                        grr.DrawImage(img2.ToBitmap(), br2.X, br2.Y);
                        grr.DrawImage(img3.ToBitmap(), br3.X, br3.Y);
                        grr.DrawImage(img4.ToBitmap(), br4.X, br4.Y);
                        grr.DrawImage(img5.ToBitmap(), br5.X, br5.Y);
                        grr.DrawImage(img6.ToBitmap(), br6.X, br6.Y);
                        grr.DrawImage(img7.ToBitmap(), br7.X, br7.Y);
                        grr.DrawImage(img8.ToBitmap(), br8.X, br8.Y);
                        grr.Dispose();
                        (resp.Data as List<object>).Add(ImageProperty.ImageToBase64(newImg, System.Drawing.Imaging.ImageFormat.Jpeg));
                    }
                    ///////////////////////////////////////
                    UserProperty.XmlUpdate("Busy", 0, false);
                    time = "";
                }
                else
                {
                    throw new Exception("Belirtilen resim bulunamadı") { Source = "" };
                }
            }
            catch (Exception e)
            {
                UserProperty.XmlUpdate("Busy", 0, false);
                UserProperty.XmlUpdate("Ticket", 1, true);
                resp.Message = e.Message;
            }
            return this.Json<QpiroJSON>(resp);
        }
Esempio n. 7
0
 public PixVolumeInfo(PixFormat format, V3i size)
 {
     Format = format; Size = size;
 }
Esempio n. 8
0
 public PixImageInfo(PixFormat format, V2i size)
 {
     Format = format; Size = size;
 }