glidex icon indicating copy to clipboard operation
glidex copied to clipboard

After install Nuget pakcage image getting large

Open amnk2015 opened this issue 5 years ago • 9 comments

I had install this nuget pakcage to my existing project. after that my images are getting large size. this will explain my issue.

https://forums.xamarin.com/discussion/153086/super-fast-image-loading-for-android-apps-with-glidex-issue/p1?new=1

image

amnk2015 avatar Apr 02 '19 08:04 amnk2015

@amnk2015 can you post some example code here?

We need to know what you're page is doing to know what's wrong, thanks!

jonathanpeppers avatar Apr 02 '19 13:04 jonathanpeppers

Thanks @jonathanpeppers for reply. I found my code issue. This is my code to get image.

<controlsCommon:ImageButton Padding="10,5,10,5" HorizontalOptions="End" Source="{ext:ThemeImageResource menu.png}" Command="{Binding MenuCommand}" />

This issue coming because of ThemeImageResource extension. Can you please give me good suggestion to solve this. is it good way to load image using extension?

using System;
using Xamarin.Forms;

namespace MyApp.ServiceMgt.Extensions
{
    [ContentProperty("Source")]
    public class ThemeImageResourceExtension : ImageResourceExtension
    {
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return Source.GetResourceImageSource(true);
        }
    }
} 

amnk2015 avatar Apr 03 '19 08:04 amnk2015

Thanks @amnk2015, can you post a little more code?

What is the source for ImageResourceExtension? The GetResourceImageSource(true) method?

Basically we need to add your issue here to our sample project--I go through and manually test it between each release.

jonathanpeppers avatar Apr 03 '19 14:04 jonathanpeppers

Please check this code.

using Xamarin.Forms;
using Application = MyApp.ServiceMgt.Code.Application;

namespace MyApp.ServiceMgt.Extensions 
{
    public static class ImageFunctions 
    {
        public static string GetResourceImagePath(this string imagePath, bool useTheme = false)
        {
            return string.IsNullOrEmpty(imagePath) ? null
                    : string.Format("MyApp.ServiceMgt.Images.{1}{0}", imagePath,
                    useTheme ? Application.Instance.Configuration.Theme + "." : string.Empty);
        }

        public static ImageSource GetResourceImageSource(this string imagePath, bool useTheme = false)
        {
            var result = GetResourceImagePath(imagePath, useTheme);
            return string.IsNullOrEmpty(result) ? null : ImageSource.FromResource(result, typeof(ImageFunctions));
        }
    }
}

amnk2015 avatar Apr 04 '19 02:04 amnk2015

So this is nothing to do with your markup extension, etc. It is something to do with EmbeddedResource.

Can you upload the actual image file here? If it's OK with you, I will put it in the sample app in this repo.

One last question: what is <controlsCommon:ImageButton/>? Can I just use an ImageButton to see the issue?

jonathanpeppers avatar Apr 04 '19 18:04 jonathanpeppers

This is the Image button control code

<?xml version="1.0" encoding="utf-8" ?>
<StackLayout xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyApp.Common.Controls.ImageButton"
    Orientation="Horizontal">
    <Image x:Name="Image" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Aspect="AspectFit" IsVisible="False" />
    <Label x:Name="Label" VerticalOptions="CenterAndExpand" IsVisible="False" />
</StackLayout>

this is the images

header_back menu

amnk2015 avatar Apr 05 '19 03:04 amnk2015

@amnk2015 I tried using your image, but things were working for me: https://github.com/jonathanpeppers/glidex/commit/a90887287c4d657aa82acd7a00620d2c7d95352d

Is it possible you are hitting a variation of: https://github.com/jonathanpeppers/glidex/issues/10#issuecomment-433109852 and https://github.com/jonathanpeppers/glidex/issues/34 ?

Currently I would recommend using WidthRequest or HeighRequest when using glidex. It also will help the performance of your layouts to know the approximate size of your images up front.

jonathanpeppers avatar Apr 10 '19 03:04 jonathanpeppers

Same issue here, the images are huge after adding the NuGet package.

mknotzer avatar May 23 '19 10:05 mknotzer

@mknotzer I was having some trouble reproducing this one. Would you be able to make a sample showing it? Thanks!

jonathanpeppers avatar May 23 '19 12:05 jonathanpeppers