Skip to content

Instantly share code, notes, and snippets.

@mattregul

mattregul/App.cs Secret

Last active January 26, 2016 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattregul/f2ca40428937e87667e2 to your computer and use it in GitHub Desktop.
Save mattregul/f2ca40428937e87667e2 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace ImageIssue
{
public class App : Application
{
public static int screenWidth;
public static int screenHeight;
AbsoluteLayout layout = new AbsoluteLayout ();
public App ()
{
ContentPage contentPage = new ContentPage ();
RenderImages ();
contentPage.Content = layout;
MainPage = contentPage;
}
private void RenderImages ()
{
int numRows = 5;
int numColumns = 5;
int numImagesRendered = 0;
int numImagesToRender = 19;
for (int i = 0; i < numRows; i++) {
for (int j = 0; j < numColumns; j++) {
if (numImagesRendered >= numImagesToRender)
return;
// LARGE IMAGE ==============================================================
//BGHouse = 829k image
// See Screenshot #1
// 287.8 MB Working Set
// 287.9 MB Max
//
//layout.Children.Add (new Image { Source = "BGHouse", Aspect = Aspect.Fill }, new Rectangle (screenWidth / numRows * i, screenHeight / numColumns * j, screenWidth / numRows, screenHeight / numColumns), AbsoluteLayoutFlags.None);
// SMALL IMAGE ==============================================================
//BGHouseSmallerSize = 46k image
// See Screenshot #2
// 287.4 MB Working Set
// 288.1 MB Max
//
layout.Children.Add (new Image { Source = "BGHouseSmallerSize", Aspect = Aspect.Fill }, new Rectangle (screenWidth / numRows * i, screenHeight / numColumns * j, screenWidth / numRows, screenHeight / numColumns), AbsoluteLayoutFlags.None);
numImagesRendered++;
}
}
}
}
}
using System;
using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace ImageIssue.Droid
{
[Activity (Label = "ImageIssue", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
protected override void OnCreate (Bundle bundle)
{
App.screenWidth = (int)(Resources.DisplayMetrics.WidthPixels / Resources.DisplayMetrics.Density);
App.screenHeight = (int)(Resources.DisplayMetrics.HeightPixels / Resources.DisplayMetrics.Density);
base.OnCreate (bundle);
global::Xamarin.Forms.Forms.Init (this, bundle);
LoadApplication (new ImageIssue.App ());
}
}
}
=== Xamarin Studio ===
Version 5.10.2 (build 53)
Installation UUID: 3477b147-e3de-47d4-87f5-4f0230db8f1e
Runtime:
Mono 4.2.2 (explicit/efae6a0)
GTK+ 2.24.23 (Raleigh theme)
Package version: 402020029
=== Xamarin.Profiler ===
Version: 0.24.0.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Xamarin.Android ===
Version: 6.0.1.9 (Enterprise Edition)
Android SDK: /Users/matthewr/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 22.0.1
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
=== Xamarin Android Player ===
Version: 0.6.5
Location: /Applications/Xamarin Android Player.app
=== Apple Developer Tools ===
Xcode 7.1.1 (9081)
Build 7B1005
=== Xamarin.iOS ===
Version: 9.4.1.23 (Enterprise Edition)
Hash: 7f1cef9
Branch: master
Build date: 2016-01-15 19:47:34-0500
=== Xamarin.Mac ===
Version: 2.4.1.5 (Enterprise Edition)
=== Xamarin Inspector ===
Version: 0.5.0.0
Hash: 45b35bb
Branch: master
Build date: Thu Jan 14 18:53:32 UTC 2016
=== Build Information ===
Release ID: 510020053
Git revision: 7ee6b4076e3f2907ae518876a91babcfdc2ea20e
Build date: 2016-01-15 11:54:57-05
Xamarin addins: 650d2ecb32cf74b3a4ac610d868925d5880f2967
Build lane: monodevelop-lion-cycle6-c6sr1
=== Operating System ===
Mac OS X 10.10.5
Darwin mMac.fios-router.home 14.5.0 Darwin Kernel Version 14.5.0
Tue Sep 1 21:23:09 PDT 2015
root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64
@mattregul
Copy link
Author

Using a Large image

image

@mattregul
Copy link
Author

Using a Small image

image

@mattregul
Copy link
Author

Sample App (modified version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment