示例#1
0
void ImageManager::ApplyBorder(ILuint DevilImageID, int32_t BorderColorID)
{
    ilBindImage(DevilImageID);
    uint8_t* ImageData = ilGetData();

    uint32_t bpp = ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL);
    uint32_t width = ilGetInteger(IL_IMAGE_WIDTH);
    uint32_t height = ilGetInteger(IL_IMAGE_HEIGHT);

    uint8_t Red, Green, Blue;
    ColorData* BorderColor = DATA->getColorData(BorderColorID);

    if(BorderColor != NULL)
    {
        Red = BorderColor->getRed();
        Green = BorderColor->getGreen();
        Blue = BorderColor->getBlue();

        if(ImageData != NULL)
        {
            for(uint32_t i = 0; i < width; i++)
            {
                ImageData[(i * width * bpp) +  0] = Blue;   // Blue
                ImageData[(i * width * bpp) +  1] = Green;  // Green
                ImageData[(i * width * bpp) +  2] = Red;    // Red

                ImageData[(i * width * bpp) +  3] = 255;    // Alpha

                ImageData[(i * width * bpp) + ((height - 1) * bpp) + 0] = Blue;     // Blue
                ImageData[(i * width * bpp) + ((height - 1) * bpp) + 1] = Green;    // Green
                ImageData[(i * width * bpp) + ((height - 1) * bpp) + 2] = Red;      // Red

                ImageData[(i * width * bpp) + ((height - 1) * bpp) + 3] = 255;      // Alpha
            }

            for(uint32_t j = 0; j < height; j++)
            {
                ImageData[((width - 1) * height * bpp) + (j * bpp) + 0] = Blue;     // Blue
                ImageData[((width - 1) * height * bpp) + (j * bpp) + 1] = Green;    // Green
                ImageData[((width - 1) * height * bpp) + (j * bpp) + 2] = Red;      // Red

                ImageData[((width - 1) * height * bpp) + (j * bpp) + 3] = 255;      // Alpha

                ImageData[(j * bpp) + 0] = Blue;    // Blue
                ImageData[(j * bpp) + 1] = Green;   // Green
                ImageData[(j * bpp) + 2] = Red;     // Red

                ImageData[(j * bpp) + 3] = 255;     // Alpha
            }
        }
    }
}
示例#2
0
/// A filter that reduce the number of possible colors  by binning each color value into the the
///number of bins specified.
/// Inherits from Filter
ColorData FQuantize::generatePixel(const PixelBuffer &buffer, int x, int y) const {
    ColorData c = buffer.getPixel(x, y);
    float red = c.getRed();
    float blue = c.getBlue();
    float green = c.getGreen();
    int steps = m_bins-1;
    red = round(red*steps)/steps;
    green = round(green*steps)/steps;
    blue = round(blue*steps)/steps;
    ColorData output(red, green, blue);

    return output;
}
示例#3
0
void Tool::apply(int xCoord, int yCoord, PixelBuffer *pixelbuff, ColorData curColor)
{
	//creating tool mask offsets for the boundary checking
	int toolHeight = this->getHeight();
	int toolWidth = this->getWidth();
	int x_offset;
	int y_offset;
	int canvas_w = pixelbuff->getWidth();
	int canvas_h = pixelbuff->getHeight();
	ColorData pixel;
	const std::vector<std::vector<float> > &tool_mask = this->mask.get_mask();
	
	//iterate through 2d vector
	for(int i = 0; i < toolHeight; i++)
	{
		y_offset = yCoord - (toolHeight/2) + i;
		if((y_offset < 0) || (y_offset >= canvas_h)) //Checking to see if mask goes out of bounds
		{
			continue;
		}
		
		for(int j = 0; j < toolWidth; j++)
		{
			x_offset = xCoord - (toolWidth/2) + j;
			if ((x_offset < 0) || (x_offset >= canvas_w)) //Checking to see if mask goes out of bounds
			{
				continue;
			}
			
			pixel = pixelbuff->getPixel(x_offset, y_offset);
			pixel.setRed((pixel.getRed()*(1 - tool_mask[i][j])) + (curColor.getRed()*tool_mask[i][j]));
			pixel.setBlue((pixel.getBlue()*(1 - tool_mask[i][j])) + (curColor.getBlue()*tool_mask[i][j]));
			pixel.setGreen((pixel.getGreen()*(1 - tool_mask[i][j])) + (curColor.getGreen()*tool_mask[i][j]));
			pixel.setAlpha((pixel.getAlpha()*(1 - tool_mask[i][j])) + tool_mask[i][j]);
			pixelbuff->setPixel(x_offset, y_offset, pixel);
		}
	}
}
void EdgeDetection::applyKernel(int x, int y,PixelBuffer* buf, PixelBuffer* temp) {
	float r=0,g=0,b=0;
	int i,j,xloc,yloc,w,h;
	ColorData pixel;
	w = buf->getWidth();
	h = buf->getHeight();
	for (i = 0; i < kernelSize; i++) {
		for (j = 0; j < kernelSize; j++) {
			xloc = x+i-(kernelSize/2);
			yloc = y+j-(kernelSize/2);
			if (xloc > -1 && xloc < w && yloc > -1 && yloc < h) {
				pixel = buf -> getPixel(x + i - (kernelSize/2),y + j - (kernelSize/2));
				r += (xKernel[i][j] * pixel.getRed());
				g += (xKernel[i][j] * pixel.getGreen());
				b += (xKernel[i][j] * pixel.getBlue());
        r += (yKernel[i][j] * pixel.getRed());
				g += (yKernel[i][j] * pixel.getGreen());
				b += (yKernel[i][j] * pixel.getBlue());
			}
		}
	}
	temp -> setPixel(x,y,ColorData(r,g,b).clampedColor());
}
示例#5
0
///apply filter effect to PixelBuffer* buffer passed into this function
void FThreshold::applyFilter(PixelBuffer * imageBuffer){
  int width = imageBuffer -> getWidth();
  int height = imageBuffer -> getHeight();
  float threshold = getFloatParameter();
  for(int i = 0; i < width; i++){
    for(int j = 0; j < height; j++){
      ColorData currPixel = imageBuffer -> getPixel(i, j);
      // if the grayscale is larger than parameter, then set pixel as white
      // otherwise, set current pixel as black
      int newRed = currPixel.getRed() > threshold ? 1.0: 0.0;
      int newBlue = currPixel.getBlue() > threshold ? 1.0 : 0.0;
      int newGreen = currPixel.getGreen() > threshold ? 1.0 : 0.0;
      imageBuffer -> setPixel(i, j, ColorData(newRed, newGreen, newBlue));

    }
  }
}
示例#6
0
void JpegFacade::save(int width,int height, PixelBuffer* pixelbuffer){
	int r,g,b,a;
	struct jpeg_compress_struct cinfo;
	struct jpeg_error_mgr jerr;
	FILE *outfile = fopen(m_filename.c_str(), "wb");
	JSAMPROW buffer[1];
	//int row_stride;
	cinfo.err = jpeg_std_error(&jerr);
	jpeg_create_compress(&cinfo);
	jpeg_stdio_dest(&cinfo, outfile);
	cinfo.image_width = width;
	cinfo.image_height = height;
	cinfo.input_components = 3;
	cinfo.in_color_space = JCS_RGB;
	jpeg_set_defaults(&cinfo);
	jpeg_set_quality(&cinfo, 100, TRUE);
	jpeg_start_compress(&cinfo, TRUE);
	//row_stride = cinfo.image_width * 3;
	//(unsigned char*)raw_image = (unsigned char*)malloc( cinfo.image_width*cinfo.image_height*cinfo.num_components );
	//number of total elements per row
	buffer[0] = (unsigned char *)malloc( cinfo.image_width*cinfo.num_components );
	int row_stride = cinfo.image_width*cinfo.input_components;
	while (cinfo.next_scanline < cinfo.image_height) {
		//buffer[0] = &raw_image[ cinfo.next_scanline * cinfo.image_width * cinfo.input_components];
		for (int i  = 0 ; i < row_stride; i=i+3){
				ColorData color = pixelbuffer->getPixel((int)i/3,cinfo.image_height-cinfo.next_scanline-1);
				r = color.getRed()*255;
				g = color.getGreen()*255;
				b = color.getBlue()*255;

				buffer[0][i] = r;
				buffer[0][i+1] = g;
				buffer[0][i+2] = b;

			}
		(void) jpeg_write_scanlines(&cinfo, buffer, 1);
	}
	//Don't need to motify, save memory
	jpeg_finish_compress(&cinfo);
	fclose(outfile);
	delete buffer[0];
	jpeg_destroy_compress(&cinfo);
}
示例#7
0
void F_Channels::applyFilter(PixelBuffer *canvas)
{
  ColorData curColor;
  float red;
  float green;
  float blue;

  for(int curX = 0; curX < canvas->getWidth(); curX++)
  {
    for (int curY = 0; curY < canvas->getHeight(); curY++)
    {
      curColor = canvas->getPixel(curX, curY);
      red = curColor.getRed() * m_filterParameter.red;
      green = curColor.getGreen() * m_filterParameter.green;
      blue = curColor.getBlue() * m_filterParameter.blue;

      canvas->setPixel(curX, curY, ColorData(red, green, blue));
    }
  }
}
示例#8
0
///apply filter effect to the PixelBuffer* buffer passed into this function
void FBlur::applyFilter(PixelBuffer* imageBuffer){
  // if kernel is already initialized, do not need initialize it again.
  kernel = buildKernel(std::round(getFloatParameter()));

  // printKernel();

  if(getName() == "FEdgeDetection"){
    imageBuffer -> convertToLuminance();
  }

  int width = imageBuffer -> getWidth();
  int height = imageBuffer -> getHeight();
  //create a new pixel buffer for storing the convolution result.
  PixelBuffer* newImageBuffer
    = new PixelBuffer(width, height, imageBuffer -> getBackgroundColor());
  for(int i = 0; i < width; i++){
    for(int j = 0; j < height; j++){
      float newRed = 0;
      float newGreen = 0;
      float newBlue = 0;
      for(size_t filterI = 0; filterI < kernel.size(); filterI++){
        for(size_t filterJ = 0; filterJ < kernel[filterI].size(); filterJ++){
          //The location imageI and imageJ is calculated so that
          //for the center element of the filter it'll be i, j
          int imageI = (i - kernel.size()/2 + filterI + width) % width;
          int imageJ = (j - kernel[filterI].size()/2 + filterJ + height) % height;
          ColorData currPixel = imageBuffer -> getPixel(imageI, imageJ);
          newRed += currPixel.getRed() * kernel[filterI][filterJ];
          newGreen += currPixel.getGreen()*kernel[filterI][filterJ];
          newBlue += currPixel.getBlue()*kernel[filterI][filterJ];
        }
      }
      ColorData newPixel = ColorData(newRed, newGreen, newBlue);
      newPixel = newPixel.clampedColor();
      newImageBuffer -> setPixel(i, j, newPixel);
    }
  }
  newImageBuffer -> copyPixelBuffer(newImageBuffer, imageBuffer);
  delete newImageBuffer;
}
示例#9
0
void Saturation::applyFilter(PixelBuffer* buffer, float saturation_amount)
{
    cout<<"Saturation";
	for (int x = 0; x < buffer->getWidth(); x ++)
    {
        for (int y = 0; y < buffer->getHeight(); y++)
        {
            ColorData currentColor = buffer->getPixel(x,y);
            float luminence = currentColor.getLuminance();
            ColorData newColor = ColorData(0,0,0);
            float redChannel = currentColor.getRed();
            float greenChannel = currentColor.getGreen();
            float blueChannel = currentColor.getBlue();
            float redDifference = (redChannel - luminence) * saturation_amount;
            float greenDifference = (greenChannel - luminence) * saturation_amount;
            float blueDifference = (blueChannel - luminence) * saturation_amount;
            newColor.setRed(luminence + redDifference);
            newColor.setGreen(luminence + greenDifference);
            newColor.setBlue(luminence + blueDifference);
            buffer->setPixel(x,y,newColor);
        }
    }
}
示例#10
0
void Stamp::applyToolOnCanvas(PixelBuffer * canvas){
	int c_width = canvas->getWidth();
	int c_height = canvas->getHeight();
	int s_width = m_stamp->getWidth();
	int s_height = m_stamp->getHeight();
	
	for(int i = 0; i < s_width; i++){
		for(int j = 0; j < s_height; j++){
			// position on canvas
			int cur_x = m_startPointx + i - s_width / 2;	
			int cur_y = m_startPointy + j - s_height / 2;

			if(cur_x < 0 || cur_y < 0 || cur_x >= canvas->getWidth() || cur_y >= canvas->getHeight()){
				continue;
			}

			ColorData c = m_stamp->getPixel(i,j);
			c.setRed(c.getRed() * m_r);
			c.setGreen(c.getGreen() * m_g);
			c.setBlue(c.getBlue() * m_b);
			canvas->setPixel(cur_x,cur_y,c);
		}
	}
}
示例#11
0
bool IPNGHandler::saveImage(const std::string fileName, const PixelBuffer* bufferToSave)
{
  cout << "IPNGHandler SAVE IMAGE" << endl;
    bool success = false;

    png_image image;

    memset(&image, 0, (sizeof image));
    image.height = bufferToSave->getHeight();
    image.width = bufferToSave->getWidth();
    image.version = PNG_IMAGE_VERSION;
    image.opaque = NULL;
    image.format = PNG_FORMAT_RGBA;

    png_bytep buffer = new png_byte[PNG_IMAGE_SIZE(image)];

    for (int y = image.height-1; y >= 0; y--) {
        for (int x = 0; x < image.width; x++) {
            ColorData currentPixel = bufferToSave->getPixel(x, y);
            buffer[((image.height-(y+1))*image.width+x)*4] = (png_byte) (currentPixel.getRed()*255.0);
            buffer[((image.height-(y+1))*image.width+x)*4+1] = (png_byte) (currentPixel.getGreen()*255.0);
            buffer[((image.height-(y+1))*image.width+x)*4+2] = (png_byte) (currentPixel.getBlue()*255.0);
            buffer[((image.height-(y+1))*image.width+x)*4+3] = (png_byte) (currentPixel.getAlpha()*255.0);
        }
    }

    if (png_image_write_to_file(&image, fileName.c_str(), 0/*convert_to_8bit*/,
                                buffer, 0/*row_stride*/, NULL/*colormap*/) != 0) {
        success = true;
    } else {
        success = false;
    }

    delete[] buffer;
    return success;
}
示例#12
0
ILuint ImageManager::GeneratedOverLayImage(ILuint TextureDevILID, int16_t PrimaryColorID, int16_t BorderColorID)
{
    ILuint TextureImageID;
    ilGenImages(1, &TextureImageID);
    ilBindImage(TextureImageID);
    ilCopyImage(TextureDevILID);
    ilConvertImage(IL_LUMINANCE_ALPHA, IL_UNSIGNED_BYTE);

    uint8_t* TextureImageData = ilGetData();
    uint32_t width = ilGetInteger(IL_IMAGE_WIDTH);
    uint32_t height = ilGetInteger(IL_IMAGE_HEIGHT);

    ColorData* PrimaryColor = DATA->getColorData(PrimaryColorID);

    ILuint NewImageID;
    ilGenImages(1, &NewImageID);
    ilBindImage(NewImageID);
    ilTexImage(width, height, 1, 4, IL_BGRA, IL_UNSIGNED_BYTE, NULL);
    uint8_t* NewImageData = ilGetData();

    uint32_t bpp = ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL);

    if(PrimaryColor != NULL)
    {
        for(uint32_t i = 0; i < width; i++)
        {
            for(uint32_t j = 0; j < height; j++)
            {
                float Base  = TextureImageData[(i * width * 2) + (j * 2) + 0];
                uint8_t Alpha =  TextureImageData[(i * width * 2) + (j * 2) + 1];
                Base /= 255.0;

                float OriginalBlue = PrimaryColor->getBlue();
                OriginalBlue /= 255.0;

                float OriginalGreen = PrimaryColor->getGreen();
                OriginalGreen /= 255.0;

                float OriginalRed = PrimaryColor->getRed();
                OriginalRed /= 255.0;

                // coloring using overlay mode
                if(Base >= 0.5)
                {
                    NewImageData[(i * width * bpp) + (j * bpp) + 0] = (1.0 - 2.0 * (1.0 - OriginalBlue) * (1.0 - Base)) * 255; // Blue
                    NewImageData[(i * width * bpp) + (j * bpp) + 1] = (1.0 - 2.0 * (1.0 - OriginalGreen) * (1.0 - Base)) * 255; // Green
                    NewImageData[(i * width * bpp) + (j * bpp) + 2] = (1.0 - 2.0 * (1.0 - OriginalRed) * (1.0 - Base)) * 255; // Red
                    NewImageData[(i * width * bpp) + (j * bpp) + 3] = Alpha;
                }
                else
                {
                    NewImageData[(i * width * bpp) + (j * bpp) + 0] = (2.0 * OriginalBlue * Base) * 255; // Blue
                    NewImageData[(i * width * bpp) + (j * bpp) + 1] = (2.0 * OriginalGreen * Base) * 255; // Green
                    NewImageData[(i * width * bpp) + (j * bpp) + 2] = (2.0 * OriginalRed * Base) * 255; // Red
                    NewImageData[(i * width * bpp) + (j * bpp) + 3] = Alpha;
                }
            }
        }
    }

    if (BorderColorID != -1)
    {
        ApplyBorder(NewImageID, BorderColorID);
    }

    return NewImageID;
}
示例#13
0
ILuint ImageManager::GenerateGradientImage(ILuint TextureDevILID, int16_t PrimaryColorID, int16_t SecondaryColorID, int16_t BorderColorID)
{
    ILuint TextureImageID;
    ilGenImages(1, &TextureImageID);
    ilBindImage(TextureImageID);
    ilCopyImage(TextureDevILID);
    ilConvertImage(IL_LUMINANCE, IL_UNSIGNED_BYTE);  //Load as IL_LUMINANCE to avoid convertion?

    uint8_t* TextureImageData = ilGetData();
    uint32_t width = ilGetInteger(IL_IMAGE_WIDTH);
    uint32_t height = ilGetInteger(IL_IMAGE_HEIGHT);

    ILuint MaskImageID;
    ilGenImages(1, &MaskImageID);
    ilBindImage(MaskImageID);
    ilTexImage(width, height, 1, 4, IL_BGRA, IL_UNSIGNED_BYTE, NULL);
    uint8_t* MaskImageData = ilGetData();

    ColorData* PrimaryColor = DATA->getColorData(PrimaryColorID);
    ColorData* SecondaryColor = DATA->getColorData(SecondaryColorID);

    uint32_t bpp = ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL);
    if(SecondaryColor != NULL)
    {
        for(uint32_t i = 0; i < width; i++)
        {
            for(uint32_t j = 0; j < height; j++)
            {
                MaskImageData[(i * width * bpp) + (j * bpp) + 0] = SecondaryColor->getBlue();     // Blue
                MaskImageData[(i * width * bpp) + (j * bpp) + 1] = SecondaryColor->getGreen();    // Green
                MaskImageData[(i * width * bpp) + (j * bpp) + 2] = SecondaryColor->getRed();      // Red
                MaskImageData[(i * width * bpp) + (j * bpp) + 3] = 255 - TextureImageData[(i * width) + j]; // Alpha
            }
        }
    }

    ILuint NewImageID;
    ilGenImages(1, &NewImageID);
    ilBindImage(NewImageID);
    ilTexImage(width, height, 1, 4, IL_BGRA, IL_UNSIGNED_BYTE, NULL);
    uint8_t* NewImageData = ilGetData();

    if(PrimaryColor != NULL)
    {
        for(uint32_t i = 0; i < width; i++)
        {
            for(uint32_t j = 0; j < height; j++)
            {
                NewImageData[(i * width * bpp) + (j * bpp) + 0] = PrimaryColor->getBlue(); // Blue
                NewImageData[(i * width * bpp) + (j * bpp) + 1] = PrimaryColor->getGreen(); // Green
                NewImageData[(i * width * bpp) + (j * bpp) + 2] = PrimaryColor->getRed(); // Red
                NewImageData[(i * width * bpp) + (j * bpp) + 3] = 255; // Alpha
            }
        }
    }

    ilOverlayImage(MaskImageID, 0, 0, 0);

    if (BorderColorID != -1)
    {
        ApplyBorder(NewImageID, BorderColorID);
    }

    return NewImageID;
}
示例#14
0
void Highlighter::draw(PixelBuffer *background, int x, int y){
 
    for (int i=0; i<15; i++){
        for (int c = 0; c < 5; c++){
            ColorData get = background->getPixel(x-2+c, y-7+i);
  //          float s=0.2126*red + 0.7152*green + 0.0722*blue;
//            float i=s*0.4;
            const ColorData& color = ColorData(red * m_mask[i][c]*get.getLuminance()+ (1-m_mask[i][c]*get.getLuminance())* get.getRed(),green * m_mask[i][c]*get.getLuminance() + (1-m_mask[i][c]*get.getLuminance()) * get.getGreen(), blue *m_mask[i][c]*get.getLuminance() + (1-m_mask[i][c]*get.getLuminance()) * get.getBlue());
            background->setPixel(x-2+c,y-7+i,color);
		}
	}
}
示例#15
0
void Stamp::setCurrentColor(ColorData color){
	m_r = color.getRed();
	m_g = color.getGreen();
	m_b = color.getBlue();
}
示例#16
0
ColorData F_MotionBlur::getBlurredColor(int canvasX, int canvasY)
{
  int distance = m_kernelSize/2;
  ColorData blurredColor;
  ColorData curPixel;
  float red = 0;
  float green = 0;
  float blue = 0;
  float colorFactor = 0;
  int curX;
  int curY;
  float kernalVal;
  assert(m_filterParameter.amountI >= 0 && m_filterParameter.amountI <= 3);
  switch(m_filterParameter.amountI)
  {
    case 0:// N/S
      for(curY = 0; curY < m_kernelSize; curY++)
      {
        curX = distance;
        int xVal= canvasX + (curX - distance);
        int yVal= canvasY + (curY - distance);

        if ((xVal >= 0) && (xVal < m_tempCanvas->getWidth()) && (yVal >= 0) && (yVal < m_tempCanvas->getHeight()))
        {
            curPixel = m_tempCanvas->getPixel(xVal, yVal);
            kernalVal = m_kernel->getKernelVal(curX, curY);
            red += kernalVal * curPixel.getRed();
            green += kernalVal * curPixel.getGreen();
            blue += kernalVal * curPixel.getBlue();
            colorFactor += kernalVal;
        }
      }
      break;
    case 1:// E/W
      for(curX = 0; curX < m_kernelSize; curX++)
      {
        curY = distance;
        int xVal= canvasX + (curX - distance);
        int yVal= canvasY + (curY - distance);

        if ((xVal >= 0) && (xVal < m_tempCanvas->getWidth()) && (yVal >= 0) && (yVal < m_tempCanvas->getHeight()))
        {
            curPixel = m_tempCanvas->getPixel(xVal, yVal);
            kernalVal = m_kernel->getKernelVal(curX, curY);
            red += kernalVal * curPixel.getRed();
            green += kernalVal * curPixel.getGreen();
            blue += kernalVal * curPixel.getBlue();
            colorFactor += kernalVal;
        }
      }
      break;
    case 2:// NE/SW
      for(curX = 0; curX < m_kernelSize; curX++)
      {
        curY = curX;
        int xVal= canvasX + (curX - distance);
        int yVal= canvasY + (curY - distance);

        if ((xVal >= 0) && (xVal < m_tempCanvas->getWidth()) && (yVal >= 0) && (yVal < m_tempCanvas->getHeight()))
        {
            curPixel = m_tempCanvas->getPixel(xVal, yVal);
            kernalVal = m_kernel->getKernelVal(curX, curY);
            red += kernalVal * curPixel.getRed();
            green += kernalVal * curPixel.getGreen();
            blue += kernalVal * curPixel.getBlue();
            colorFactor += kernalVal;
        }
      }
      break;
    case 3:// NW/SE
      for(curX = 0; curX < m_kernelSize; curX++)
      {
        curY = m_kernelSize - curX - 1;
        int xVal= canvasX + (curX - distance);
        int yVal= canvasY + (curY - distance);

        if ((xVal >= 0) && (xVal < m_tempCanvas->getWidth()) && (yVal >= 0) && (yVal < m_tempCanvas->getHeight()))
        {
            curPixel = m_tempCanvas->getPixel(xVal, yVal);
            kernalVal = m_kernel->getKernelVal(curX, curY);
            red += kernalVal * curPixel.getRed();
            green += kernalVal * curPixel.getGreen();
            blue += kernalVal * curPixel.getBlue();
            colorFactor += kernalVal;
        }
      }
      break;
    default:
      for(curX = 0; curX < m_kernelSize; curX++)
      {
        for(curY = 0; curY < m_kernelSize; curY++)
        {
          int xVal= canvasX + (curX - distance);
          int yVal= canvasY + (curY - distance);

          if ((xVal >= 0) && (xVal < m_tempCanvas->getWidth()) && (yVal >= 0) && (yVal < m_tempCanvas->getHeight()))
          {
              curPixel = m_tempCanvas->getPixel(xVal, yVal);
              kernalVal = m_kernel->getKernelVal(curX, curY);
              red += kernalVal * curPixel.getRed();
              green += kernalVal * curPixel.getGreen();
              blue += kernalVal * curPixel.getBlue();
              colorFactor += kernalVal;
          }

        }
      }
  }

  red /= colorFactor;
  green /= colorFactor;
  blue /= colorFactor;

  blurredColor = ColorData(red, green, blue);

  return blurredColor;
}