diff --git a/Rebracer.xml b/Rebracer.xml index 8497d212ea..9b0a654d21 100644 --- a/Rebracer.xml +++ b/Rebracer.xml @@ -22,8 +22,12 @@ + 0 + 0 1 - 1 + 1 + -1 + -1 0 1 0 @@ -81,7 +85,7 @@ 1 0 1 - 1 + 0 0 0 1 diff --git a/src/ImageProcessorCore/PixelAccessor.cs b/src/ImageProcessorCore/PixelAccessor.cs index 3f40f4b3c4..2553b2536d 100644 --- a/src/ImageProcessorCore/PixelAccessor.cs +++ b/src/ImageProcessorCore/PixelAccessor.cs @@ -16,7 +16,7 @@ namespace ImageProcessorCore /// /// The position of the first pixel in the bitmap. /// - private float* pixelsBase; + private Color* pixelsBase; /// /// Provides a way to access the pixels from unmanaged memory. @@ -48,27 +48,12 @@ namespace ImageProcessorCore Guard.MustBeGreaterThan(image.Width, 0, "image width"); Guard.MustBeGreaterThan(image.Height, 0, "image height"); - int size = image.Pixels.Length; this.Width = image.Width; this.Height = image.Height; // Assign the pointer. - // If buffer is allocated on Large Object Heap i.e > 85Kb, then we are going to pin it instead of making a copy. - if (size > 87040) - { - this.pixelsHandle = GCHandle.Alloc(image.Pixels, GCHandleType.Pinned); - this.pixelsBase = (float*)this.pixelsHandle.AddrOfPinnedObject().ToPointer(); - } - else - { - fixed (float* pbuffer = image.Pixels) - { - // TODO: This isn't actually copying. - // We need to allocate and copy the pixels into unmanaged memory. - // Will need to research how to do this. - this.pixelsBase = pbuffer; - } - } + this.pixelsHandle = GCHandle.Alloc(image.Pixels, GCHandleType.Pinned); + this.pixelsBase = (Color*)this.pixelsHandle.AddrOfPinnedObject().ToPointer(); } /// @@ -116,7 +101,7 @@ namespace ImageProcessorCore throw new ArgumentOutOfRangeException(nameof(y), "Value cannot be less than zero or greater than the bitmap height."); } #endif - return *((Color*)(this.pixelsBase + (((y * this.Width) + x) * 4))); + return *(this.pixelsBase + ((y * this.Width) + x)); } set @@ -132,7 +117,7 @@ namespace ImageProcessorCore throw new ArgumentOutOfRangeException(nameof(y), "Value cannot be less than zero or greater than the bitmap height."); } #endif - *(Color*)(this.pixelsBase + (((y * this.Width) + x) * 4)) = value; + *(this.pixelsBase + ((y * this.Width) + x)) = value; } }