Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    164

    How to re size source image in custom filter effect?

    What I need is simple. I want to re size the original image and change the color of whole image to a solid color(white).
    Then blending the above obtained image with the original image so that a neat border is displayed around the image. I want to implement above method in custom filter effect but don't know how to do it.

    This is how I re size the image.
    public async void resize(IImageProvider source)
    {
    Windows.Foundation.Size dimensions = (await source.GetInfoAsync()).ImageSize;

    var newWidth = (int)(dimensions.Width + 16);
    var newHeight = (int)(dimensions.Height + 16);

    WriteableBitmap bitmap = new WriteableBitmap(newWidth, newHeight);

    using (WriteableBitmapRenderer renderer = new WriteableBitmapRenderer(source, bitmap, OutputOption.PreserveAspectRatio))
    {
    var wbm = await renderer.RenderAsync();
    }
    }
    Please help me in adding border around the image.
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

  2. #2
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    481

    Re: How to re size source image in custom filter effect?

    Hi.
    Have You try to use blendingfilter?
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  3. #3
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    164

    Re: How to re size source image in custom filter effect?

    No! In custom filter effect how to re-size the original image and pass the resized image parameter to base?

    How should I re size and use Blend filter in below code.

    public class DoubleEffect : CustomEffectBase
    {
    public DoubleEffect(IImageProvider source) : base(source)
    {
    }

    protected override void OnProcess(PixelRegion sourcePixelRegion, PixelRegion targetPixelRegion)
    {
    sourcePixelRegion.ForEachRow((index, width, pos) =>
    {
    for (int x = 0; x < width; ++x, ++index)
    {
    uint color = sourcePixelRegion.ImagePixels[index];

    // Extract color channel values
    var a = (byte)((color >> 24) & 255);
    var r = (byte)((color >> 16) & 255);
    var g = (byte)((color >> 8) & 255);
    var b = (byte)((color) & 255);

    r = (byte)Math.Min(255, r * 2);
    g = (byte)Math.Min(255, g * 2);
    b = (byte)Math.Min(255, b * 2);

    // Combine modified color channels
    var newColor = (uint)(b | (g << 8) | (r << 16) | (a << 24));

    targetPixelRegion.ImagePixels[index] = newColor;
    }
    });
    }
    }
    Last edited by venu238; 2014-05-04 at 03:08.
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

  4. #4
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    481

    Re: How to re size source image in custom filter effect?

    Resizing is done by the pipeline and depend on renderer output size or reframing/crop filter used.

    I don't understand what you want do exactly. Could you make a schemas?

    May the fourth be with you
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  5. #5
    Regular Contributor
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    481

    Re: How to re size source image in custom filter effect?

    Resizing is done by the pipeline and depend on renderer output size or reframing/crop filter used.

    I don't understand what you want do exactly. Could you make a schemas?

    May the fourth be with you
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  6. #6
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    164

    Re: How to re size source image in custom filter effect?

    Click image for larger version. 

Name:	Untitled.jpg 
Views:	483 
Size:	23.7 KB 
ID:	1585 I want all the above steps to be included in a custom filter.
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

  7. #7
    Registered User
    Join Date
    May 2014
    Posts
    10

    Re: How to re size source image in custom filter effect?

    (edited with 1.2 info)

    In version 1.2 and above:

    BlendFilter has a new property "TargetArea". This lets you position/scale the foreground source. So a your background, use a ColorImageSource the size and color you want. Blend the FG on top and position/size it appropriately.

    In versions 1.1 and below:

    - Make a ColorImageSource (white) at the larger size.This will be your background source.
    - Your photo is the foreground source. Apply a ReframingFilter to expand the border around the image to make it the size of the white bg. The "new" border area is transparent.
    - Blend the foreground onto the bg.

    Both approaches are block based and memory efficient, like a custom filter is.
    Last edited by cadahl; 2014-05-31 at 20:11.

  8. #8
    Regular Contributor
    Join Date
    Jan 2014
    Posts
    164

    Re: How to re size source image in custom filter effect?

    Thanks for the suggestion but I can't do the same if foreground image has some transparent part. So I've implemented a custom filter instead of Blend.
    Check out the discussion about the same topic here..
    http://developer.nokia.com/community...two-png-images
    Clipr: Best ever image clipping tool and first of it's kind in windows phone!!

    Download here
    http://www.windowsphone.com/s?appid=d533f018-238a-429c-affc-55a46c2dc69f

Similar Threads

  1. Custom Quad Transformation effect Nokia Imaging SDK
    By hmilkovi in forum Windows Phone Imaging
    Replies: 2
    Last Post: 2014-04-23, 18:12
  2. How to code marquee effect in custom istbox
    By topocheng in forum Symbian
    Replies: 5
    Last Post: 2009-10-24, 10:06
  3. How to capture image in custom size?
    By Mozart2007 in forum Symbian
    Replies: 5
    Last Post: 2009-04-28, 10:32
  4. Replies: 2
    Last Post: 2008-05-08, 05:14
  5. Different image editor program effect to file size?
    By tamtam4247229 in forum Mobile Java General
    Replies: 4
    Last Post: 2004-08-16, 18:30

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×