aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2019-01-16 20:24:16 +0000
committerUbitUmarov2019-01-16 20:24:16 +0000
commitb2810c4ca718663f2bbc8c86646444d698873352 (patch)
treed29311e6cd4032fd5fa55f7c390782f9031f0da2 /OpenSim/Region
parentmantis 8442 change alpha blending note BREAKING CHANGEgit push! old scripts u... (diff)
downloadopensim-SC-b2810c4ca718663f2bbc8c86646444d698873352.zip
opensim-SC-b2810c4ca718663f2bbc8c86646444d698873352.tar.gz
opensim-SC-b2810c4ca718663f2bbc8c86646444d698873352.tar.bz2
opensim-SC-b2810c4ca718663f2bbc8c86646444d698873352.tar.xz
mantis 8442 more changes to alpha blending
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs78
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs8
2 files changed, 63 insertions, 23 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
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 475e8e9..00e4e78 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -354,6 +354,10 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
354 // under lock. 354 // under lock.
355 lock (this) 355 lock (this)
356 { 356 {
357
358 if (alpha == 256 && bgColor.A != 255)
359 alpha = bgColor.A;
360
357 if (alpha == 256) 361 if (alpha == 256)
358 { 362 {
359 bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb); 363 bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
@@ -367,13 +371,15 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
367 { 371 {
368 bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); 372 bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
369 graph = Graphics.FromImage(bitmap); 373 graph = Graphics.FromImage(bitmap);
374
370 Color newbg = Color.FromArgb(alpha,bgColor); 375 Color newbg = Color.FromArgb(alpha,bgColor);
371 using (SolidBrush bgFillBrush = new SolidBrush(newbg)) 376 using (SolidBrush bgFillBrush = new SolidBrush(newbg))
372 { 377 {
378 graph.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
373 graph.FillRectangle(bgFillBrush, 0, 0, width, height); 379 graph.FillRectangle(bgFillBrush, 0, 0, width, height);
374 } 380 }
375 } 381 }
376 382 graph.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
377 GDIDraw(data, graph, altDataDelim, out reuseable); 383 GDIDraw(data, graph, altDataDelim, out reuseable);
378 } 384 }
379 385