diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | 78 |
1 files changed, 56 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 53a5fd1..2d9e503 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |||
@@ -625,51 +625,85 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
625 | { | 625 | { |
626 | Bitmap joint; | 626 | Bitmap joint; |
627 | Graphics jG; | 627 | Graphics jG; |
628 | if(alpha >= 255) | 628 | int Width = back.Width; |
629 | int Height = back.Height; | ||
630 | |||
631 | PixelFormat format; | ||
632 | if(alpha < 255 || front.PixelFormat == PixelFormat.Format32bppArgb || back.PixelFormat == PixelFormat.Format32bppArgb) | ||
633 | format = PixelFormat.Format32bppArgb; | ||
634 | else | ||
635 | format = PixelFormat.Format32bppRgb; | ||
636 | |||
637 | joint = new Bitmap(Width, Height, format); | ||
638 | |||
639 | if (alpha >= 255) | ||
629 | { | 640 | { |
630 | joint = new Bitmap(back.Width, back.Height, PixelFormat.Format32bppArgb); | ||
631 | using (jG = Graphics.FromImage(joint)) | 641 | using (jG = Graphics.FromImage(joint)) |
632 | { | 642 | { |
633 | jG.CompositingMode = CompositingMode.SourceOver; | ||
634 | jG.CompositingQuality = CompositingQuality.HighQuality; | 643 | jG.CompositingQuality = CompositingQuality.HighQuality; |
635 | 644 | ||
636 | jG.DrawImage(back, 0, 0, back.Width, back.Height); | 645 | jG.CompositingMode = CompositingMode.SourceCopy; |
637 | jG.DrawImage(front, 0, 0, back.Width, back.Height); | 646 | jG.DrawImage(back, 0, 0, Width, Height); |
647 | |||
648 | jG.CompositingMode = CompositingMode.SourceOver; | ||
649 | jG.DrawImage(front, 0, 0, Width, Height); | ||
638 | return joint; | 650 | return joint; |
639 | } | 651 | } |
640 | } | 652 | } |
641 | ColorMatrix matrix = new ColorMatrix(new float[][]{ | ||
642 | new float[] {1F, 0, 0, 0, 0}, | ||
643 | new float[] {0, 1F, 0, 0, 0}, | ||
644 | new float[] {0, 0, 1F, 0, 0}, | ||
645 | new float[] {0, 0, 0, alpha/255f, 0}, | ||
646 | new float[] {0, 0, 0, 0, 1F}}); | ||
647 | 653 | ||
648 | ImageAttributes imageAttributes = new ImageAttributes(); | ||
649 | |||
650 | imageAttributes.SetColorMatrix(matrix); | ||
651 | joint = new Bitmap(back.Width, back.Height, PixelFormat.Format32bppArgb); | ||
652 | using (jG = Graphics.FromImage(joint)) | 654 | using (jG = Graphics.FromImage(joint)) |
653 | { | 655 | { |
654 | jG.CompositingMode = CompositingMode.SourceOver; | ||
655 | jG.CompositingQuality = CompositingQuality.HighQuality; | 656 | jG.CompositingQuality = CompositingQuality.HighQuality; |
657 | jG.CompositingMode = CompositingMode.SourceCopy; | ||
658 | jG.DrawImage(back, 0, 0, Width, Height); | ||
659 | |||
660 | if (alpha > 0) | ||
661 | { | ||
662 | ColorMatrix matrix = new ColorMatrix(new float[][]{ | ||
663 | new float[] {1F, 0, 0, 0, 0}, | ||
664 | new float[] {0, 1F, 0, 0, 0}, | ||
665 | new float[] {0, 0, 1F, 0, 0}, | ||
666 | new float[] {0, 0, 0, alpha/255f, 0}, | ||
667 | new float[] {0, 0, 0, 0, 1F}}); | ||
668 | |||
669 | ImageAttributes imageAttributes = new ImageAttributes(); | ||
670 | imageAttributes.SetColorMatrix(matrix); | ||
671 | |||
672 | jG.CompositingMode = CompositingMode.SourceOver; | ||
673 | jG.DrawImage(front, new Rectangle(0, 0, Width, Height), 0, 0, front.Width, front.Height, GraphicsUnit.Pixel, imageAttributes); | ||
674 | } | ||
656 | 675 | ||
657 | jG.DrawImage(back, 0, 0, back.Width, back.Height); | ||
658 | if(alpha > 0) | ||
659 | jG.DrawImage(front, new Rectangle(0, 0, back.Width, back.Height), 0, 0, front.Width, front.Height, GraphicsUnit.Pixel,imageAttributes); | ||
660 | return joint; | 676 | return joint; |
661 | } | 677 | } |
662 | } | 678 | } |
663 | 679 | ||
664 | private void SetAlpha(ref Bitmap b, byte alpha) | 680 | private void SetAlpha(ref Bitmap b, byte alpha) |
665 | { | 681 | { |
666 | for (int w = 0; w < b.Width; w++) | 682 | int Width = b.Width; |
683 | int Height = b.Height; | ||
684 | Bitmap joint = new Bitmap(Width, Height, PixelFormat.Format32bppArgb); | ||
685 | if(alpha > 0) | ||
667 | { | 686 | { |
668 | for (int h = 0; h < b.Height; h++) | 687 | ColorMatrix matrix = new ColorMatrix(new float[][]{ |
688 | new float[] {1F, 0, 0, 0, 0}, | ||
689 | new float[] {0, 1F, 0, 0, 0}, | ||
690 | new float[] {0, 0, 1F, 0, 0}, | ||
691 | new float[] {0, 0, 0, alpha/255f, 0}, | ||
692 | new float[] {0, 0, 0, 0, 1F}}); | ||
693 | |||
694 | ImageAttributes imageAttributes = new ImageAttributes(); | ||
695 | imageAttributes.SetColorMatrix(matrix); | ||
696 | |||
697 | using (Graphics jG = Graphics.FromImage(joint)) | ||
669 | { | 698 | { |
670 | b.SetPixel(w, h, Color.FromArgb(alpha, b.GetPixel(w, h))); | 699 | jG.CompositingQuality = CompositingQuality.HighQuality; |
700 | jG.CompositingMode = CompositingMode.SourceCopy; | ||
701 | jG.DrawImage(b, new Rectangle(0, 0, Width, Height), 0, 0, Width, Height, GraphicsUnit.Pixel, imageAttributes); | ||
671 | } | 702 | } |
672 | } | 703 | } |
704 | Bitmap t = b; | ||
705 | b = joint; | ||
706 | t.Dispose(); | ||
673 | } | 707 | } |
674 | } | 708 | } |
675 | 709 | ||