Skip to content

Commit

Permalink
[NUI] Support ImageView and ImageVisual the SamplingMode
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunki, Hong committed Sep 24, 2024
1 parent 0b18460 commit 7bdbe0a
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ private static string ConvertResourceUrl(ref string value)
ImageVisualProperty.AlphaMaskURL,
ImageVisualProperty.CropToMask,
Visual.Property.VisualFittingMode,
ImageVisualProperty.SamplingMode,
ImageVisualProperty.DesiredWidth,
ImageVisualProperty.DesiredHeight,
ImageVisualProperty.ReleasePolicy,
Expand Down Expand Up @@ -1288,6 +1289,43 @@ private FittingModeType InternalFittingMode
}
}

/// <summary>
/// Gets or sets filtering options used when resizing images to the sample original pixels.<br />
/// If not supplied, the default is SamplingModeType.BoxThenLinear.<br />
/// For normal quad images only.<br />
/// Optional.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public SamplingModeType SamplingMode
{
get
{
return InternalSamplingMode;
}
set
{
InternalSamplingMode = value;
NotifyPropertyChanged();
}
}
private SamplingModeType InternalSamplingMode
{
get
{
int ret = (int)SamplingModeType.BoxThenLinear;

using PropertyValue samplingMode = GetCachedImageVisualProperty(ImageVisualProperty.SamplingMode);
samplingMode?.Get(out ret);

return (SamplingModeType)ret;
}
set
{
using PropertyValue setValue = new PropertyValue((int)value);
UpdateImage(ImageVisualProperty.SamplingMode, setValue);
}
}

/// <summary>
/// This method allows users to configure the blending of two images(previous and currnet) using alpha values.
/// </summary>
Expand Down
12 changes: 11 additions & 1 deletion src/Tizen.NUI/src/public/Visuals/VisualConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,17 @@ public enum SamplingModeType
/// <summary>
/// For caching algorithms where a client strongly prefers a cache-hit to reuse a cached image.
/// </summary>
DontCare
DontCare,
/// <summary>
/// Use Lanczos resample algorithm.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
Lanczos,
/// <summary>
/// Iteratively box filter to generate an image of 1/2, 1/4, 1/8 etc width and height and approximately the desired size, then apply Lanczos resample algorithm.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
BoxThenLanczos,
}

/// <summary>
Expand Down
22 changes: 22 additions & 0 deletions src/Tizen.NUI/src/public/Visuals/VisualObject/ImageVisual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,28 @@ public ReleasePolicyType ReleasePolicy
}
}

/// <summary>
/// Gets or sets filtering options used when resizing images to the sample original pixels.<br />
/// If not supplied, the default is SamplingModeType.BoxThenLinear.<br />
/// For normal quad images only.<br />
/// Optional.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public SamplingModeType SamplingMode
{
set
{
UpdateVisualProperty((int)Tizen.NUI.ImageVisualProperty.SamplingMode, new PropertyValue((int)value));
}
get
{
int ret = (int)SamplingModeType.BoxThenLinear;
var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.ImageVisualProperty.SamplingMode);
propertyValue?.Get(out ret);
return (SamplingModeType)ret;
}
}

/// <summary>
/// Gets or sets the desired image width.<br />
/// If not specified, the actual image width is used.<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ private View CreateViewWithVisual(int id)

SynchronousSizing = true,

SamplingMode = SamplingModeType.BoxThenLanczos,

OffsetXPolicy = VisualTransformPolicyType.Absolute,
OffsetYPolicy = VisualTransformPolicyType.Absolute,
WidthPolicy = VisualTransformPolicyType.Absolute,
Expand Down

0 comments on commit 7bdbe0a

Please sign in to comment.