locked
WriteableBitmap image

    Question

  • My User control needs a dynamic image where I used WriteableBitmap which works fine but if the source image has a 45 degree line it shows steps instead of line which implies it is not blending with background. I am using WriteableBitmapExtensions.BlendMode.Alpha  mode. It works fine but result looks ugly.

    Your help will be very much appreciated.


    Agha Khan

    Sunday, May 11, 2014 11:20 PM

All replies

  • This should be something to do with resolution you have chosen. Can you try with higher resolution and better pixel density. That should help you. If not post a sample here with a way to replicate the issue. I am sure that way you can get better response.

    -- Vishal Kaushik --

    Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you. Happy Coding!!!

    Monday, May 12, 2014 7:58 AM
  • Dear Vishal Kaushik:
    Thank you for prompt reply. My application supports all the resolutions, so I can't ignore it. It works fine if I am not using WriteableBitmap, but there is a need to copy multiple images in to a big image. I will post my sample today.
     
    Once again thanks
    Agha Khan 

    PS: kindly give me the address where to mail my sample


    Agha Khan

    Monday, May 12, 2014 2:07 PM
  • I have created new sample application and uploaded to skyDrive, but without your email I am unable to share the sample code. Please send me your email to agha.khan@Hotmail.com 

    Agha Khan

    Tuesday, May 13, 2014 12:16 AM
  • https://onedrive.live.com/redir?resid=ED95A04E7576C8D8%219273

    There are two samples (basically same sample).

    1. ImageRotation (image disappears while rotating an image (angle 45 degree to 135 degree)

    2. Writeable image (why Bad output)

    Best regards

    Agha Khan


    Agha Khan

    Tuesday, May 13, 2014 2:06 AM
  • Hello Agha, I have just downloaded your apps. I will have a look at this in my day time tomorrow and get back to you.

    -- Vishal Kaushik --

    Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you. Happy Coding!!!

    Tuesday, May 13, 2014 7:04 PM
  • I looked into your projects and have concluded that it is quality of your images that causes dashed lines in WriteableImage.zip. I just edited 2 of them in Visual Studio to add lines and that looks fine. In this solution there is no issue of image disappears while rotating an image (angle 45 degree to 135 degree)

    See these:

    For the other solution you were not using your converter BuildDynamicImage that uses WriteableBitmap. Ther you had a custom control named CustomListBox. I changed it to derive from ItemsControl and it fixes the issue of disappearing images. I think there is some Animation in ListBox that in combination of yours causes issue. After following change you will have to recalculate position of your items as ItemsControl will not add its padding and margin for each item.

    public class CustomListBox : ItemsControl
        {
            protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
            {
                var nutInfo = item as NutInfo;
                var source = element as FrameworkElement;
                if (nutInfo != null && source != null)
                {
                    base.PrepareContainerForItemOverride(element, item);
                    source.RenderTransform = new TranslateTransform { X = Common.GetLocation()[nutInfo.LocationIndex].X, Y = Common.GetLocation()[nutInfo.LocationIndex].Y };
                }
            }
        }


    -- Vishal Kaushik --

    Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you. Happy Coding!!!

    Wednesday, May 14, 2014 7:15 PM
  • Dear Vishal Kaushik:

    Thank you very much for your answer. The problem is if same image use directly it works fine but if I use as a WriteableImage it looks ugly. The problem with ListBox is not related to WriteableImage image, because I was using as a background. I have disappearing images has been resolved and nothing to do with ItemsControl but rather it was not adding "CacheMode. Basically the problem is still there but I am not sure why WriteableImage gives bad output for same image. In your case you are modifying the input image which seems not correct approach as I think Any way thanks for help. 


    Agha Khan

    Wednesday, May 14, 2014 10:36 PM