| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | import { Image as ImageDefinition, Stretch } from "."; | |
| 2 | - import { View, Property, InheritedCssProperty, Style, Color, isIOS, booleanConverter } from "../core/view"; | ||
| 2 | + import { View, Property, InheritedCssProperty, Length, Style, Color, isIOS, booleanConverter } from "../core/view"; | ||
| 3 | 3 | import { ImageAsset } from "../../image-asset"; | |
| 4 | 4 | import { ImageSource, fromAsset, fromNativeSource, fromUrl } from "../../image-source"; | |
| 5 | 5 | import { isDataURI, isFileOrResourcePath, RESOURCE_PREFIX } from "../../utils/utils"; | |
@@ -13,6 +13,8 @@ export abstract class ImageBase extends View implements ImageDefinition { | |||
| 13 | 13 | public isLoading: boolean; | |
| 14 | 14 | public stretch: Stretch; | |
| 15 | 15 | public loadMode: "sync" | "async"; | |
| 16 | + public decodeWidth: Length; | ||
| 17 | + public decodeHeight: Length; | ||
| 16 | 18 | ||
| 17 | 19 | get tintColor(): Color { | |
| 18 | 20 | return this.style.tintColor; | |
@@ -118,4 +120,10 @@ export const stretchProperty = new Property<ImageBase, Stretch>({ name: "stretch | |||
| 118 | 120 | stretchProperty.register(ImageBase); | |
| 119 | 121 | ||
| 120 | 122 | export const tintColorProperty = new InheritedCssProperty<Style, Color>({ name: "tintColor", cssName: "tint-color", equalityComparer: Color.equals, valueConverter: (value) => new Color(value) }); | |
| 121 | - tintColorProperty.register(Style); | ||
| 123 | + tintColorProperty.register(Style); | ||
| 124 | + | ||
| 125 | + export const decodeHeightProperty = new Property<ImageBase, Length>({ name: "decodeHeight", defaultValue: { value: 0, unit: "dip" }, valueConverter: Length.parse }); | ||
| 126 | + decodeHeightProperty.register(ImageBase); | ||
| 127 | + | ||
| 128 | + export const decodeWidthProperty = new Property<ImageBase, Length>({ name: "decodeWidth", defaultValue: { value: 0, unit: "dip" }, valueConverter: Length.parse }); | ||
| 129 | + decodeWidthProperty.register(ImageBase); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | import { | |
| 2 | 2 | ImageSource, ImageAsset, ImageBase, stretchProperty, imageSourceProperty, srcProperty, tintColorProperty, Color, | |
| 3 | - isDataURI, isFileOrResourcePath, RESOURCE_PREFIX | ||
| 3 | + isDataURI, isFileOrResourcePath, RESOURCE_PREFIX, Length | ||
| 4 | 4 | } from "./image-common"; | |
| 5 | 5 | import { knownFolders } from "../../file-system"; | |
| 6 | 6 | ||
@@ -43,16 +43,14 @@ function initializeImageLoadedListener() { | |||
| 43 | 43 | export class Image extends ImageBase { | |
| 44 | 44 | nativeViewProtected: org.nativescript.widgets.ImageView; | |
| 45 | 45 | ||
| 46 | - public decodeWidth = 0; | ||
| 47 | - public decodeHeight = 0; | ||
| 48 | 46 | public useCache = true; | |
| 49 | 47 | ||
| 50 | 48 | public createNativeView() { | |
| 51 | 49 | if (!AndroidImageView) { | |
| 52 | 50 | AndroidImageView = org.nativescript.widgets.ImageView; | |
| 53 | 51 | } | |
| 54 | 52 | initializeImageLoadedListener(); | |
| 55 | - | ||
| 53 | + | ||
| 56 | 54 | const imageView = new AndroidImageView(this._context); | |
| 57 | 55 | const listener = new ImageLoadedListener(this); | |
| 58 | 56 | imageView.setImageLoadedListener(listener); | |
@@ -73,7 +71,7 @@ export class Image extends ImageBase { | |||
| 73 | 71 | ||
| 74 | 72 | public resetNativeView(): void { | |
| 75 | 73 | super.resetNativeView(); | |
| 76 | - this.nativeViewProtected.setImageMatrix(new android.graphics.Matrix()); | ||
| 74 | + this.nativeViewProtected.setImageMatrix(new android.graphics.Matrix()); | ||
| 77 | 75 | } | |
| 78 | 76 | ||
| 79 | 77 | public _createImageSourceFromSrc(value: string | ImageSource | ImageAsset) { | |
@@ -89,8 +87,8 @@ export class Image extends ImageBase { | |||
| 89 | 87 | ||
| 90 | 88 | let screen = platform.screen.mainScreen; | |
| 91 | 89 | ||
| 92 | - let decodeWidth = Math.min(this.decodeWidth, screen.widthPixels); | ||
| 93 | - let decodeHeight = Math.min(this.decodeHeight, screen.heightPixels); | ||
| 90 | + let decodeWidth = Math.min(Length.toDevicePixels(this.decodeWidth, 0), screen.widthPixels); | ||
| 91 | + let decodeHeight = Math.min(Length.toDevicePixels(this.decodeHeight, 0), screen.heightPixels); | ||
| 94 | 92 | let keepAspectRatio = this._calculateKeepAspectRatio(); | |
| 95 | 93 | if (value instanceof ImageAsset) { | |
| 96 | 94 | if (value.options) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments