Skip to content

Commit a1ff43e

Browse files
committed
BitmapImage: added pixelSnapping and smoothing properties
1 parent 51e42d6 commit a1ff43e

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/feathers/controls/BitmapImage.hx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
package feathers.controls;
1010

11+
import openfl.display.PixelSnapping;
1112
import feathers.core.FeathersControl;
1213
import feathers.core.IValidating;
1314
import feathers.layout.Measurements;
@@ -34,11 +35,13 @@ class BitmapImage extends FeathersControl {
3435
3536
@since 1.4.0
3637
**/
37-
public function new(?source:BitmapData) {
38+
public function new(?source:BitmapData, pixelSnapping:PixelSnapping = AUTO, smoothing:Bool = false) {
3839
initializeBitmapImageTheme();
3940
super();
4041

4142
this.source = source;
43+
this.pixelSnapping = pixelSnapping;
44+
this.smoothing = smoothing;
4245
}
4346

4447
private var content:Bitmap;
@@ -187,6 +190,18 @@ class BitmapImage extends FeathersControl {
187190
return this._scaleMode;
188191
}
189192

193+
/**
194+
@see [`openfl.display.Bitmap.pixelSnapping`](https://api.openfl.org/openfl/display/Bitmap.html#pixelSnapping)
195+
**/
196+
@:style
197+
public var pixelSnapping:PixelSnapping = AUTO;
198+
199+
/**
200+
@see [`openfl.display.Bitmap.smoothing`](https://api.openfl.org/openfl/display/Bitmap.html#smoothing)
201+
**/
202+
@:style
203+
public var smoothing:Bool = false;
204+
190205
private function initializeBitmapImageTheme():Void {
191206
#if !feathersui_disable_default_theme
192207
feathers.themes.steel.components.SteelBitmapImageStyles.initialize();
@@ -199,6 +214,16 @@ class BitmapImage extends FeathersControl {
199214
}
200215

201216
override private function update():Void {
217+
var dataInvalid = this.isInvalid(DATA);
218+
var stylesInvalid = this.isInvalid(STYLES);
219+
220+
if (dataInvalid || stylesInvalid) {
221+
if (this.content != null) {
222+
this.content.pixelSnapping = this.pixelSnapping;
223+
this.content.smoothing = this.smoothing;
224+
}
225+
}
226+
202227
this.measure();
203228
this.layoutChildren();
204229
}
@@ -354,6 +379,6 @@ class BitmapImage extends FeathersControl {
354379
}
355380

356381
private function createBitmap(bitmapData:BitmapData):Bitmap {
357-
return new Bitmap(bitmapData);
382+
return new Bitmap(bitmapData, this.pixelSnapping, this.smoothing);
358383
}
359384
}

0 commit comments

Comments
 (0)