void ReallocLut(double radius) { m_radius = radius; m_diameter = AggBasics.uceil(radius) * 2; m_start = -(m_diameter / 2 - 1); int size = m_diameter << ImgSubPixConst.SHIFT; if (size > m_weight_array.Length) { m_weight_array = new int[size]; } }
// Create //-------------------------------------------------------------------- public void Create(IImageReaderWriter src) { // we are going to create a dialated image for filtering // we add m_dilation pixels to every side of the image and then copy the image in the x // dirrection into each end so that we can sample into this image to get filtering on x repeating // if the original image look like this // // 123456 // // the new image would look like this // // 0000000000 // 0000000000 // 5612345612 // 0000000000 // 0000000000 m_height = (int)AggBasics.uceil(src.Height); m_width = (int)AggBasics.uceil(src.Width); m_width_hr = (int)AggBasics.uround(src.Width * LineAA.SUBPIXEL_SCALE); m_half_height_hr = (int)AggBasics.uround(src.Height * LineAA.SUBPIXEL_SCALE / 2); m_offset_y_hr = m_dilation_hr + m_half_height_hr - LineAA.SUBPIXEL_SCALE / 2; m_half_height_hr += LineAA.SUBPIXEL_SCALE / 2; int bufferWidth = m_width + m_dilation * 2; int bufferHeight = m_height + m_dilation * 2; int bytesPerPixel = src.BitDepth / 8; int newSizeInBytes = bufferWidth * bufferHeight * bytesPerPixel; if (m_DataSizeInBytes < newSizeInBytes) { m_DataSizeInBytes = newSizeInBytes; m_data = new byte[m_DataSizeInBytes]; } m_buf = new ChildImage(m_data, 0, bufferWidth, bufferHeight, bufferWidth * bytesPerPixel, src.BitDepth, bytesPerPixel); byte[] destBuffer = m_buf.GetBuffer(); byte[] srcBuffer = src.GetBuffer(); // copy the image into the middle of the dest for (int y = 0; y < m_height; y++) { for (int x = 0; x < m_width; x++) { int sourceOffset = src.GetBufferOffsetXY(x, y); int destOffset = m_buf.GetBufferOffsetXY(m_dilation, y + m_dilation); for (int channel = 0; channel < bytesPerPixel; channel++) { destBuffer[destOffset++] = srcBuffer[sourceOffset++]; } } } // copy the first two pixels form the end into the begining and from the begining into the end for (int y = 0; y < m_height; y++) { int s1Offset = src.GetBufferOffsetXY(0, y); int d1Offset = m_buf.GetBufferOffsetXY(m_dilation + m_width, y); int s2Offset = src.GetBufferOffsetXY(m_width - m_dilation, y); int d2Offset = m_buf.GetBufferOffsetXY(0, y); for (int x = 0; x < m_dilation; x++) { for (int channel = 0; channel < bytesPerPixel; channel++) { destBuffer[d1Offset++] = srcBuffer[s1Offset++]; destBuffer[d2Offset++] = srcBuffer[s2Offset++]; } } } }