Ejemplo n.º 1
0
        public void RedrawBitmap()
        {
            bitmap = null;

            if (artData != null)
            {
                if (!stocked)
                {
                    bitmap = artData[dataIndex];
                }
                else
                {
                    Bitmap art = artData[dataIndex];

                    // Offset 5,5 is client-hardcoded
                    // Note: PixelFormat is NEEDED!
                    bitmap = new Bitmap(art.Width + 5, art.Height + 5, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    // Draw second image over the first one
                    using (Graphics g = Graphics.FromImage(bitmap)) {
                        g.DrawImageUnscaled(art, 0, 0);
                        g.DrawImageUnscaled(art, 5, 5);
                    }
                }

                if (useHue && hues != null)
                {
                    HueEntry entry = hues[hueIndex];
                    if (entry != null)
                    {
                        Dyes.RecolorFull(entry, bitmap);
                    }
                }
            }

            Invalidate();
        }
Ejemplo n.º 2
0
        public void RedrawBitmap()
        {
            bitmap = null;

            if (artData != null)
            {
                this.BackColor = Color.Black;
                Bitmap art = artData[dataIndex];

                if (useHue && hues != null)
                {
                    try
                    {
                        HueEntry entry = hues[hueIndex];
                        if (entry != null)
                        {
                            Dyes.RecolorFull(entry, art);
                        }
                    }
                    catch { }
                }

                if (!stocked)
                {
                    bitmap = art;
                }
                else
                {
                    bitmap = new Bitmap(art.Width + 5, art.Height + 5, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    int minX = 0;
                    int minY = 0;
                    int maxX = 0;
                    int maxY = 0;

                    for (int x = 0; x < art.Width; x++)
                    {
                        for (int y = 0; y < art.Height; y++)
                        {
                            Color c = art.GetPixel(x, y);
                            if (c.IsEmpty || (c.R + c.G + c.G < 12))
                            {
                            }                             //Odstin moc blizky cerne { }
                            else
                            {
                                if (minX == 0 || x < minX)
                                {
                                    minX = x;
                                }

                                if (minY == 0 || y < minY)
                                {
                                    minY = y;
                                }

                                if (x > maxX)
                                {
                                    maxX = x;
                                }

                                if (y > maxY)
                                {
                                    maxY = y;
                                }
                            }
                        }
                    }

                    Color borderColor = Color.LightGray;
                    if (Selection)
                    {
                        borderColor = Color.Yellow;
                    }
                    else if (Selected)
                    {
                        borderColor = Color.DeepSkyBlue;
                    }

                    Color markColor = borderColor;//Color.Crimson;
                    if (this.Mark1)
                    {
                        markColor = Color.Crimson;
                    }


                    for (int x = minX; x < maxX; x++)
                    {
                        art.SetPixel(x, minY, markColor);

                        art.SetPixel(x, maxY - 1, borderColor);
                        art.SetPixel(x, maxY, borderColor);
                    }

                    for (int y = minY; y < maxY; y++)
                    {
                        art.SetPixel(minX, y, borderColor);

                        art.SetPixel(maxX - 1, y, markColor);
                        art.SetPixel(maxX, y, markColor);
                    }

                    if (Grayscale)
                    {
                        int x, y;
                        for (x = 0; x < art.Width; x++)
                        {
                            for (y = 0; y < art.Height; y++)
                            {
                                Color pixelColor = art.GetPixel(x, y);
                                Color newColor   = Color.FromArgb(pixelColor.R, 0, 0);
                                art.SetPixel(x, y, newColor); // Now greyscale
                            }
                        }
                    }

                    using (Graphics g = Graphics.FromImage(bitmap))
                    {
                        g.DrawImage(art, new Rectangle(0, 0, this.Width, this.Height), new Rectangle(minX, minY, maxX - minX, maxY - minY), GraphicsUnit.Pixel);
                        if (this.counter.HasValue)
                        {
                            g.FillRectangle(Brushes.Black, 0, 0, 12, 12);
                            g.DrawString(String.Format("{0}", this.counter), new Font("Arial", CounterTextFontSize), CounterBrush, 0, 1);
                        }
                    }
                }
            }
            else
            {
                this.BackColor = Color.LightGray;
            }

            Invalidate();
        }