Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After install Nuget pakcage image getting large #32

Open
amnk2015 opened this issue Apr 2, 2019 · 9 comments
Open

After install Nuget pakcage image getting large #32

amnk2015 opened this issue Apr 2, 2019 · 9 comments
Labels
need-info I need more info?

Comments

@amnk2015
Copy link

amnk2015 commented Apr 2, 2019

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

@jonathanpeppers
Copy link
Owner

@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 jonathanpeppers added the need-info I need more info? label Apr 2, 2019
@amnk2015
Copy link
Author

amnk2015 commented Apr 3, 2019

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);
        }
    }
} 

@jonathanpeppers
Copy link
Owner

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.

@amnk2015
Copy link
Author

amnk2015 commented Apr 4, 2019

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));
        }
    }
}

@jonathanpeppers
Copy link
Owner

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?

@amnk2015
Copy link
Author

amnk2015 commented Apr 5, 2019

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

jonathanpeppers added a commit that referenced this issue Apr 10, 2019
* Cleanup `.csproj` in general
* Rework `MainPage` to use `ListView`

Added sample for: #32
@jonathanpeppers
Copy link
Owner

@amnk2015 I tried using your image, but things were working for me: a908872

Is it possible you are hitting a variation of: #10 (comment) and #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.

@mknotzer
Copy link

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

@jonathanpeppers
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-info I need more info?
Projects
None yet
Development

No branches or pull requests

3 participants