Beispiel #1
0
        /// <summary>
        /// Text Zone'u iki eşit parçaya böler
        /// </summary>
        /// <param name="outImage"></param>
        /// <param name="zone"></param>
        /// <returns></returns>
        protected OutImage[] SeparateTextZone(OutImage outImage, Zone zone)
        {
            MyImaging myImg = new MyImaging();

            Graphics grp = Graphics.FromImage(outImage.Img);

            OutImage[] separetedZones = { new OutImage(), new OutImage() };

            //ortadaki karakteri çizme
            //grp.DrawLine(new Pen(Brushes.Red), 0, zone.Chars[zone.Chars.Count / 2 ].ZoneRect.Top - 2, outImage.Img.Width, zone.Chars[zone.Chars.Count / 2].ZoneRect.Top - 2);

            //grp.DrawRectangle(new Pen(Brushes.Red), new Rectangle((int)zone.Chars[zone.Chars.Count / 2].ZoneRect.X, (int)zone.Chars[zone.Chars.Count / 2].ZoneRect.Y,(int) zone.Chars[zone.Chars.Count / 2].ZoneRect.Width,(int) zone.Chars[zone.Chars.Count / 2].ZoneRect.Height));


            #region Text Zone'u ortadaki karalteri baz alarak ikiye bölme işlemi

            try
            {
                Region cropRegion = new Region(new RectangleF(0, 0, outImage.Img.Width, zone.Chars[zone.Chars.Count / 2].ZoneRect.Top - 5));

                separetedZones[0].Img = myImg.Crop(outImage.Img, cropRegion);

                separetedZones[0].Reg = cropRegion;


                Region cropRegion2 = new Region(new RectangleF(0, cropRegion.GetBounds(grp).Height, outImage.Img.Width, outImage.Img.Height - cropRegion.GetBounds(grp).Height));

                separetedZones[1].Img = myImg.Crop(outImage.Img, cropRegion2);

                separetedZones[1].Reg = cropRegion2;
            }
            catch (Exception)
            {
                throw new Exception("Text Zone Parçalanamıyor.Karakter bilgisi doğru gelmemiş olabilir.");
            }

            #endregion
            grp.Dispose();
            return(separetedZones);
        }
Beispiel #2
0
        public override IList <OutElements.OutPage> Process(IList <InElements.InPage> pages)
        {
            MyImaging myImg = new MyImaging();

            IList <OutPage> outPages = new List <OutPage>();

            OutPage outPage = new OutPage(); //Ana sayfa

            float endHeightPoint = 5;
            float endWidthPoint;
            float headerBottomPoint = 5;
            int   pageColumn;
            float lastZoneXPoint;
            float imageBottomPoint;
            float scale;
            int   pageHeight = Utils.ConvertMMtoPixel(268, 72), pageWidth = Utils.ConvertMMtoPixel(190, 72);



            foreach (InPage page in pages)
            {
                pageColumn     = 1;
                lastZoneXPoint = 0;
                endWidthPoint  = 5;
                #region Header Yerleştirme

                foreach (Zone zone in page.Zones)
                {
                    //Sayfanın üst kısmına Header Yerleştirme.
                    if (zone.Type == ZoneType.Header)
                    {
                        OutImage outImage = new OutImage();

                        outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                        scale = 72 / outImage.Img.HorizontalResolution;

                        outImage.Img = Decrease72Dpi(outImage.Img, scale);

                        Graphics grp = Graphics.FromImage(outImage.Img);


                        outImage.Reg     =
                            outImage.Reg =
                                new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale,
                                                          zone.Reg.GetBounds(grp).Y *scale, zone.Reg.GetBounds(grp).Width *scale,
                                                          zone.Reg.GetBounds(grp).Height *scale));

                        while (outImage.Img.Width > pageWidth)
                        {
                            outImage.Img = myImg.ResizeFast(outImage.Img, (int)(outImage.Img.Width * (0.90)),
                                                            (int)(outImage.Img.Height * (0.90)));
                        }

                        int leftSpace = (pageWidth - outImage.Img.Width) / 2;

                        outImage.LocationPixel = new PointF(leftSpace, endHeightPoint);

                        endHeightPoint += outImage.Img.Height + 5;

                        headerBottomPoint = endHeightPoint;

                        endWidthPoint = 5;

                        outPage.Images.Add(outImage);

                        grp.Dispose();
                    }
                }

                #endregion

                #region Text Zone'ları Yerleştirme

                SortedDictionary <int, Zone> sortedTextZones = SelectAndSortTextZones(page.Zones);
                //Text Zone'ların Sıralanması işlemi.

                //Text Zoneları yerleştirme.
                foreach (Zone zone in sortedTextZones.Values)
                {
                    OutImage outImage = new OutImage();

                    outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                    scale = 72 / outImage.Img.HorizontalResolution;

                    outImage.Img = Decrease72Dpi(outImage.Img, scale);

                    CalculateCharRect(zone, outImage.Img, scale);

                    Graphics grp = Graphics.FromImage(outImage.Img);


                    outImage.Reg =
                        new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale, zone.Reg.GetBounds(grp).Y *scale,
                                                  zone.Reg.GetBounds(grp).Width *scale, zone.Reg.GetBounds(grp).Height *scale));



                    //TextZone'un Sayafayanın kalan alanına sığıp sığamadığının kontrolü yapılır.
                    if (outImage.Reg.GetBounds(grp).Height > (pageHeight - endHeightPoint))
                    {
                        //Sığmıyorsa sayfadaki yeni bir Text kolonuna sığıp sığamadığının kontrolü. Orayada sığmıyorsa Parçalama işlemi yapılır. Sığıyorsa yeni kolona yerleştrilir.
                        if (pageColumn == 1 && outImage.Reg.GetBounds(grp).Height > (pageHeight - endHeightPoint) &&
                            outImage.Reg.GetBounds(grp).Height / 2 < (pageHeight - endHeightPoint))
                        {
                            OutImage[] separatedImages = SeparateTextZone(outImage, zone);

                            for (int i = 0; i < separatedImages.Length; i++)
                            {
                                separatedImages[i].LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                lastZoneXPoint += endWidthPoint;



                                if (i != separatedImages.Length - 1)
                                //son parça text zone olup olmadığına göre 2. kolon için değerleri ayarlama
                                {
                                    endWidthPoint += separatedImages[i].Img.Width + 10;
                                    endHeightPoint = headerBottomPoint;//HATAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa- Yukarıdaki text in width i yerine kesilmiş olan textin with ini alıyor
                                }
                                else
                                {
                                    endHeightPoint += separatedImages[i].Img.Height;
                                }
                                pageColumn = i + 1;
                                outPage.Images.Add(separatedImages[i]);
                            }
                        }
                        else
                        {
                            if (outImage.Img.Width < pageWidth - lastZoneXPoint &&
                                outImage.Img.Height < pageHeight - headerBottomPoint)
                            //yeni kolona sığıyor mu kontrolü yapılır sığmıyorsa yeni page oluşturulur.
                            {
                                endWidthPoint = lastZoneXPoint + 10;

                                outImage.LocationPixel = new PointF(endWidthPoint, headerBottomPoint);

                                endHeightPoint = outImage.Img.Height + headerBottomPoint;

                                lastZoneXPoint = endWidthPoint + outImage.Img.Width;

                                pageColumn++;


                                outPage.Images.Add(outImage);
                            }
                            else
                            {
                                outPages.Add(outPage); //ilk sayfayı listeye ekle yeni bir sayfa aç
                                OutPage newOutPage = new OutPage();
                                endWidthPoint     = 5;
                                endHeightPoint    = 5;
                                pageColumn        = 1;
                                headerBottomPoint = 5;

                                if (outImage.Img.Height < pageHeight - headerBottomPoint)
                                //yeni sayfaya sığıyorsa yerleştir.
                                {
                                    outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                    endHeightPoint += outImage.Img.Height;
                                    lastZoneXPoint  = endWidthPoint + outImage.Img.Width;

                                    newOutPage.Images.Add(outImage);

                                    pageHeight = Utils.ConvertMMtoPixel(282, 72);
                                    //yeni sayfa için yükseklik değerini günceleldik.


                                    outPage = newOutPage;
                                }
                                else //yeni sayfaya sığmıyorsa parçalayıp yerleştir.
                                {
                                    OutImage[] separatedImages = SeparateTextZone(outImage, zone);

                                    for (int i = 0; i < separatedImages.Length; i++)
                                    {
                                        separatedImages[i].LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                        lastZoneXPoint += endWidthPoint;



                                        if (i != separatedImages.Length - 1)
                                        //son parça text zone olup olmadığına göre 2. kolon için değerleri ayarlama
                                        {
                                            endWidthPoint += separatedImages[i].Img.Width + 10;
                                            endHeightPoint = headerBottomPoint;
                                        }
                                        else
                                        {
                                            endHeightPoint += separatedImages[i].Img.Height;
                                        }
                                        pageColumn = i + 1;

                                        outPage = newOutPage;

                                        outPage.Images.Add(separatedImages[i]);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (pageColumn != 1)
                        {
                            outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                            endHeightPoint += outImage.Img.Height;

                            lastZoneXPoint = endWidthPoint + outImage.Img.Width;

                            outPage.Images.Add(outImage);
                        }
                        else
                        {
                            float leftspace = 0;
                            if (sortedTextZones.Count == 1)
                            {
                                leftspace = (pageWidth - outImage.Img.Width - 5) / 2;
                            }
                            outImage.LocationPixel = new PointF(endWidthPoint + leftspace, endHeightPoint);

                            endHeightPoint += outImage.Img.Height;


                            if (lastZoneXPoint < endWidthPoint + outImage.Img.Width)//Text zone'larından en geniş olanının değerini sakla (image yazının üstüne gelmemesi için)
                            {
                                lastZoneXPoint = endWidthPoint + outImage.Img.Width;
                            }

                            outPage.Images.Add(outImage);
                        }
                    }

                    grp.Dispose();
                }

                #endregion
            }


            outPages.Add(outPage);


            return(outPages);
        }
Beispiel #3
0
        public override IList <OutElements.OutPage> Process(IList <InElements.InPage> pages)
        {
            MyImaging myImg = new MyImaging();

            IList <OutPage> outPages = new List <OutPage>();

            OutPage outPage = new OutPage(); //İlk Syafa

            float endHeightPoint = 5;
            float endWidthPoint;
            float headerBottomPoint = 5;
            int   pageColumn;
            float lastZoneXPoint;
            float scale;
            int   pageHeight = Utils.ConvertMMtoPixel(268, 72), pageWidth = Utils.ConvertMMtoPixel(190, 72);

            foreach (InPage page in pages)
            {
                pageColumn     = 1;
                lastZoneXPoint = 0;
                endWidthPoint  = 5;

                #region Header Yerleştirme
                foreach (Zone zone in page.Zones)
                {
                    //Sayfanın üst kısmına Header Yerleştirme.
                    if (zone.Type == ZoneType.Header)
                    {
                        OutImage outImage = new OutImage();

                        outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                        scale = 72 / outImage.Img.HorizontalResolution;

                        outImage.Img = Decrease72Dpi(outImage.Img, scale);

                        Graphics grp = Graphics.FromImage(outImage.Img);


                        outImage.Reg = outImage.Reg = new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale, zone.Reg.GetBounds(grp).Y *scale, zone.Reg.GetBounds(grp).Width *scale, zone.Reg.GetBounds(grp).Height *scale));

                        while (outImage.Img.Width > pageWidth)
                        {
                            outImage.Img = myImg.ResizeFast(outImage.Img, (int)(outImage.Img.Width * (0.90)), (int)(outImage.Img.Height * (0.90)));
                        }

                        int leftSpace = (pageWidth - outImage.Img.Width) / 2;

                        outImage.LocationPixel = new PointF(leftSpace, endHeightPoint);

                        endHeightPoint += outImage.Img.Height + 5;

                        headerBottomPoint = endHeightPoint;

                        endWidthPoint = 5;

                        outPage.Images.Add(outImage);

                        grp.Dispose();
                    }
                }
                #endregion

                #region Title Yerleşirme (Opsiyonel Eğer varsa)

                foreach (Zone zone in page.Zones)
                {
                    //Sayfanın üst kısmına Header Yerleştirme.
                    if (zone.Type == ZoneType.Title)
                    {
                        OutImage outImage = new OutImage();

                        outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                        scale = 72 / outImage.Img.HorizontalResolution;

                        outImage.Img = Decrease72Dpi(outImage.Img, scale);

                        Graphics grp = Graphics.FromImage(outImage.Img);


                        outImage.Reg = outImage.Reg = new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale, zone.Reg.GetBounds(grp).Y *scale, zone.Reg.GetBounds(grp).Width *scale, zone.Reg.GetBounds(grp).Height *scale));

                        while (outImage.Img.Width > pageWidth)
                        {
                            outImage.Img = myImg.ResizeFast(outImage.Img, (int)(outImage.Img.Width * (0.90)), (int)(outImage.Img.Height * (0.90)));
                        }

                        int leftSpace = (pageWidth - outImage.Img.Width) / 2;

                        outImage.LocationPixel = new PointF(leftSpace, endHeightPoint);

                        endHeightPoint += outImage.Img.Height + 5;

                        headerBottomPoint = endHeightPoint;

                        endWidthPoint = 5;

                        outPage.Images.Add(outImage);

                        grp.Dispose();
                    }
                }


                #endregion

                #region Image Yerleştirme

                endHeightPoint += 5;

                foreach (Zone zone in page.Zones)
                {
                    //Sayfanın alt kısmına Image Yerleştirme.
                    if (zone.Type == ZoneType.Image)
                    {
                        OutImage outImage = new OutImage();

                        outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                        scale = 72 / outImage.Img.HorizontalResolution;

                        outImage.Img = Decrease72Dpi(outImage.Img, scale);

                        Graphics grp = Graphics.FromImage(outImage.Img);

                        outImage.Reg = outImage.Reg = new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale, zone.Reg.GetBounds(grp).Y *scale, zone.Reg.GetBounds(grp).Width *scale, zone.Reg.GetBounds(grp).Height *scale));

                        int maxResizeCount = 1;

                        Bitmap tempImage = Interpress.Library.Libraries.DbtLibrary.Image.Image.Clone(outImage.Img);


                        while (tempImage.Width > pageWidth - lastZoneXPoint && maxResizeCount < 6)//sağa yerleştirebilmek için %20 küçülterek ilerle
                        {
                            tempImage = myImg.ResizeFast(tempImage, (int)(tempImage.Width * (0.80)), (int)(tempImage.Height * (0.80)));

                            maxResizeCount++;

                            if (maxResizeCount == 6)
                            {
                                tempImage = (Bitmap)outImage.Img.Clone();

                                while (tempImage.Height > pageHeight - endHeightPoint && maxResizeCount < 11) //aşağı yerleştirebilmek için %20 küçülterek ilerle
                                {
                                    tempImage = myImg.ResizeFast(tempImage, (int)(tempImage.Width * (0.80)),
                                                                 (int)(tempImage.Height * (0.80)));
                                    maxResizeCount++;
                                }
                            }
                        }
                        if (0 < maxResizeCount && maxResizeCount < 6) //sağa yerleştirmeye
                        {
                            if (pageColumn == 1)                      //tek kolan var ise yeni kolona yerleştir sığmıyorsa yeni sayfa yarat
                            {
                                if (tempImage.Height < pageHeight - headerBottomPoint)
                                {
                                    outImage.Img           = (Bitmap)tempImage.Clone();
                                    outImage.LocationPixel = new PointF(lastZoneXPoint, headerBottomPoint);
                                    //yeni
                                    endWidthPoint   = lastZoneXPoint;
                                    lastZoneXPoint += outImage.Img.Width;

                                    if (endHeightPoint < headerBottomPoint + outImage.Img.Height)              //sayfa yatayındaki en uzun heigth point noktasını tut.Zone'lar üstüste gelmemesi için.
                                    {
                                        endHeightPoint = headerBottomPoint + outImage.Img.Height;
                                    }


                                    pageColumn++;
                                }

                                else
                                {
                                    maxResizeCount = 11;
                                }
                            }

                            else if (tempImage.Height < pageHeight - endHeightPoint)     //birden fazla kolon var ise son zone'un altına sığıyorsa yerleştir.sığmıyorsa yeni sayfa yarat.
                            {
                                outImage.Img           = (Bitmap)tempImage.Clone();
                                outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);
                                //yeni
                                endHeightPoint += outImage.Img.Height + 5;
                                lastZoneXPoint += outImage.Img.Width;
                            }
                            else
                            {
                                maxResizeCount = 11;
                            }
                        }


                        else if (5 < maxResizeCount && maxResizeCount < 11) //alta yerleştir
                        {
                            if (tempImage.Width < pageWidth - endWidthPoint)
                            //genişliği sığıyosarsa yerleştir sığmıyor ise yeni sayfa yarat.
                            {
                                outImage.Img           = outImage.Img = (Bitmap)tempImage.Clone();
                                outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);
                                //yeni
                                endHeightPoint += outImage.Img.Height + 5;
                                lastZoneXPoint  = endWidthPoint + outImage.Img.Width;
                            }
                            else
                            {
                                maxResizeCount = 11;
                            }
                        }


                        if (maxResizeCount == 11)   // Syafaya Sığmadı. Yeni page yaratıp ona yerleştir.
                        {
                            outPages.Add(outPage);  //sayfayı kaydet yeni bir sayfas oluştur



                            OutPage newOutPage = new OutPage();


                            while (tempImage.Width > pageWidth)
                            {
                                tempImage = myImg.ResizeFast(tempImage, (int)(tempImage.Width * (0.80)), (int)(tempImage.Height * (0.80)));
                            }

                            endWidthPoint     = 5;
                            endHeightPoint    = 5;
                            pageColumn        = 1;
                            headerBottomPoint = 5;

                            outImage.Img = (Bitmap)tempImage.Clone();

                            outImage.Reg = new Region(new RectangleF(endWidthPoint, endHeightPoint, tempImage.Width, tempImage.Height));

                            outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                            lastZoneXPoint  = outImage.Img.Width + endWidthPoint;
                            endHeightPoint += outImage.Img.Height + 5;

                            pageHeight = Utils.ConvertMMtoPixel(282, 72);         //yeni sayfa için yükseklik değerini günceleldik.

                            newOutPage.Images.Add(outImage);

                            outPage = newOutPage;
                        }
                        else  //ilk sayfaya sığdı region değerlerini düzeltiyoruz ve ilk sayfaya ekliyoruz.
                        {
                            outImage.Reg = new Region(new RectangleF(outImage.LocationPixel.X, outImage.LocationPixel.Y, tempImage.Width, tempImage.Height));


                            outPage.Images.Add(outImage);
                        }

                        tempImage.Dispose();
                        grp.Dispose();
                    }
                }


                #endregion

                #region Text Zone'ları Yerleştirme

                SortedDictionary <int, Zone> sortedTextZones = SelectAndSortTextZones(page.Zones); //Text Zone'ların Sıralanması işlemi.

                //Text Zoneları yerleştirme.
                foreach (Zone zone in sortedTextZones.Values)
                {
                    OutImage outImage = new OutImage();

                    outImage.Img = GetCroppedAndBlackWhite(page.Img, zone);

                    scale = 72 / outImage.Img.HorizontalResolution;

                    outImage.Img = Decrease72Dpi(outImage.Img, scale);

                    CalculateCharRect(zone, outImage.Img, scale);

                    Graphics grp = Graphics.FromImage(outImage.Img);


                    outImage.Reg = new Region(new RectangleF(zone.Reg.GetBounds(grp).X *scale, zone.Reg.GetBounds(grp).Y *scale, zone.Reg.GetBounds(grp).Width *scale, zone.Reg.GetBounds(grp).Height *scale));



                    //TextZone'un Sayafayanın kalan alanına sığıp sığamadığının kontrolü yapılır.
                    if (outImage.Reg.GetBounds(grp).Height > (pageHeight - endHeightPoint))
                    {
                        //Sığmıyorsa sayfadaki yeni bir Text kolonuna sığıp sığamadığının kontrolü. Orayada sığmıyorsa Parçalama işlemi yapılır. Sığıyorsa yeni kolona yerleştrilir.
                        if (pageColumn == 1 && outImage.Reg.GetBounds(grp).Height > (pageHeight - endHeightPoint) &&
                            outImage.Reg.GetBounds(grp).Height / 2 < (pageHeight - endHeightPoint))
                        {
                            OutImage[] separatedImages = SeparateTextZone(outImage, zone);

                            for (int i = 0; i < separatedImages.Length; i++)
                            {
                                separatedImages[i].LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                lastZoneXPoint += endWidthPoint;



                                if (i != separatedImages.Length - 1)
                                //son parça text zone olup olmadığına göre 2. kolon için değerleri ayarlama
                                {
                                    endWidthPoint += separatedImages[i].Img.Width + 10;
                                    endHeightPoint = headerBottomPoint;
                                }
                                else
                                {
                                    endHeightPoint += separatedImages[i].Img.Height;
                                }
                                pageColumn = i + 1;
                                outPage.Images.Add(separatedImages[i]);
                            }
                        }
                        else
                        {
                            if (outImage.Img.Width < pageWidth - lastZoneXPoint && outImage.Img.Height < pageHeight - headerBottomPoint)
                            //yeni kolona sığıyor mu kontrolü yapılır sığmıyorsa yeni page oluşturulur.
                            {
                                endWidthPoint = lastZoneXPoint + 10;

                                outImage.LocationPixel = new PointF(endWidthPoint, headerBottomPoint);

                                endHeightPoint = outImage.Img.Height + headerBottomPoint;

                                lastZoneXPoint = endWidthPoint + outImage.Img.Width;

                                pageColumn++;


                                outPage.Images.Add(outImage);
                            }
                            else
                            {
                                outPages.Add(outPage); //ilk sayfayı listeye ekle yeni bir sayfa aç
                                OutPage newOutPage = new OutPage();
                                endWidthPoint     = 5;
                                endHeightPoint    = 5;
                                pageColumn        = 1;
                                headerBottomPoint = 5;

                                if (outImage.Img.Height < pageHeight - headerBottomPoint) //yeni sayfaya sığıyorsa yerleştir.
                                {
                                    outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                    endHeightPoint += outImage.Img.Height;
                                    lastZoneXPoint  = endWidthPoint + outImage.Img.Width;

                                    newOutPage.Images.Add(outImage);

                                    pageHeight = Utils.ConvertMMtoPixel(282, 72);
                                    //yeni sayfa için yükseklik değerini günceleldik.


                                    outPage = newOutPage;
                                }
                                else                                            //yeni sayfaya sığmıyorsa parçalayıp yerleştir.
                                {
                                    OutImage[] separatedImages = SeparateTextZone(outImage, zone);

                                    for (int i = 0; i < separatedImages.Length; i++)
                                    {
                                        separatedImages[i].LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                                        lastZoneXPoint += endWidthPoint;



                                        if (i != separatedImages.Length - 1)
                                        //son parça text zone olup olmadığına göre 2. kolon için değerleri ayarlama
                                        {
                                            endWidthPoint += separatedImages[i].Img.Width + 10;
                                            endHeightPoint = headerBottomPoint;
                                        }
                                        else
                                        {
                                            endHeightPoint += separatedImages[i].Img.Height;
                                        }
                                        pageColumn = i + 1;

                                        outPage = newOutPage;

                                        outPage.Images.Add(separatedImages[i]);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (pageColumn != 1)
                        {
                            outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                            endHeightPoint += outImage.Img.Height;

                            lastZoneXPoint = endWidthPoint + outImage.Img.Width;

                            outPage.Images.Add(outImage);
                        }
                        else
                        {
                            outImage.LocationPixel = new PointF(endWidthPoint, endHeightPoint);

                            endHeightPoint += outImage.Img.Height;

                            if (lastZoneXPoint < endWidthPoint + outImage.Img.Width)   //Text zone'larından en geniş olanının değerini sakla (image yazının üstüne gelmemesi için)
                            {
                                lastZoneXPoint = endWidthPoint + outImage.Img.Width;
                            }

                            outPage.Images.Add(outImage);
                        }
                    }

                    grp.Dispose();
                }

                #endregion
            }


            outPages.Add(outPage); //son sayfada eklenir.


            return(outPages);
        }
Beispiel #4
0
        public CIELab RGBtoLAB(int x, int y)
        {
            double var_R, var_G, var_B, X, Y, Z, ref_X = 95.047, ref_Y = 100.000, ref_Z = 108.883; //reference D65 2*
            CIELab c1;

            var_R = (OutImage.GetPixel(x, y).R / 255.0);
            var_G = (OutImage.GetPixel(x, y).G / 255.0);
            var_B = (OutImage.GetPixel(x, y).B / 255.0);

            if (var_R > 0.04045)
            {
                var_R = Math.Pow((var_R + 0.055) / 1.055, 2.4);
            }
            else
            {
                var_R /= 12.92;
            }
            if (var_G > 0.04045)
            {
                var_G = Math.Pow((var_G + 0.055) / 1.055, 2.4);
            }
            else
            {
                var_G /= 12.92;
            }
            if (var_B > 0.04045)
            {
                var_B = Math.Pow((var_B + 0.055) / 1.055, 2.4);
            }
            else
            {
                var_B /= 12.92;
            }

            var_R *= 100.0;
            var_G *= 100.0;
            var_B *= 100.0;

            X = var_R * 0.4124 + var_G * 0.3576 + var_B * 0.1805;
            Y = var_R * 0.2126 + var_G * 0.7152 + var_B * 0.0722;
            Z = var_R * 0.0193 + var_G * 0.1192 + var_B * 0.9505;

            X /= ref_X;
            Y /= ref_Y;
            Z /= ref_Z;

            if (X > 0.008856)
            {
                X = Math.Pow(X, (1.0 / 3.0));
            }
            else
            {
                X = (7.787 * X) + (16.0 / 116.0);
            }
            if (Y > 0.008856)
            {
                Y = Math.Pow(Y, (1.0 / 3.0));
            }
            else
            {
                Y = (7.787 * Y) + (16.0 / 116.0);
            }
            if (Z > 0.008856)
            {
                Z = Math.Pow(Z, (1.0 / 3.0));
            }
            else
            {
                Z = (7.787 * Z) + (16.0 / 116.0);
            }

            c1.L = (116.0 * Y) - 16.0;
            c1.a = 500.0 * (X - Y);
            c1.b = 200.0 * (Y - Z);

            return(c1);
        }