【转载】downRight关于菱形图像的分割(求解)

1、用 Loader 载入图像
2、将载入的图像转为 BitmapData
3、按照X,Y轴 进行遍历
4、画一个菱形 shape 并转为 BitmapData
5、用PNGEncoder 或者JPGEncoder 载入 BitmapData 图像特定区域(固定大小)的 ByteArray
6、载入FileStream保存该位置的图像

但是问题在于 要得到图像特定区域的 ByteArray 只能使用 getPixels 取得 Rectangle 矩形块,如何才能将图像按照特定区块(非矩形)方式遍历保存呢?

问题解决补充:首先,建一个 矩形区块 BitmapData(w,h),然后用copyPixels,在原图中截取一个Rectangle(x,y,w,h),复制到BitmapData的point(0,0)位置,这样就得到一个要填充菱形区块的矩形了,然后以填充的方式填充到自己画好的菱形中去,输出BitmapData,获取BitmapData的byteArray,然后将其输出到PNGEncoder 或 JPGEncoder 转存为图像,这就已经可以得到不同位置的高质量菱形位图了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
USTRUCT(BlueprintType) struct MPBASE_API FGeoCorners { GENERATED_BODY() UPROPERTY(EditAnywhere, Category = "GeoTypes | Corners") FGeoPosition UpLeft; UPROPERTY(EditAnywhere, Category = "GeoTypes | Corners") FGeoPosition UpRight; UPROPERTY(EditAnywhere, Category = "GeoTypes | Corners") FGeoPosition DownLeft; UPROPERTY(EditAnywhere, Category = "GeoTypes | Corners") FGeoPosition DownRight; FGeoBoundingBox ToBoundingBox() const; }; USTRUCT(BlueprintType) struct MPBASE_API FGeoBoundingBox { GENERATED_BODY() UPROPERTY(EditAnywhere, Category = "GeoTypes | BoundingBox") FGeoPosition MinLocation; UPROPERTY(EditAnywhere, Category = "GeoTypes | BoundingBox") FGeoPosition MaxLocation; FGeoBoundingBox() = default; FGeoBoundingBox(double minx, double miny, double maxx, double maxy) : MinLocation(minx, miny), MaxLocation(maxx, maxy) { } FGeoBoundingBox(const FGeoPosition& minLoc, const FGeoPosition& maxLoc) : MinLocation(minLoc), MaxLocation(maxLoc) { } bool IsValid() const { return MinLocation.IsValid() && MaxLocation.IsValid() && MinLocation <= MaxLocation; } bool Contains(const FGeoPosition& location) const { return location.Longitude >= MinLocation.Longitude && location.Latitude >= MinLocation.Latitude && location.Longitude <= MaxLocation.Longitude && location.Latitude <= MaxLocation.Latitude; } FGeoBoundingBox& operator+=(const FGeoPosition& Location); FGeoBoundingBox& operator+=(const FGeoBoundingBox& GeoBox); bool Intersect(const FGeoBoundingBox& Other) const; bool Contains(const FGeoBoundingBox& Other) const; FGeoBoundingBox Intersection(const FGeoBoundingBox& Other) const; bool IsInside(const FGeoPosition & TestPoint) const { return ((TestPoint.Longitude > MinLocation.Longitude) && (TestPoint.Longitude < MaxLocation.Longitude) && (TestPoint.Latitude > MinLocation.Latitude) && (TestPoint.Latitude < MaxLocation.Latitude)); } bool IsInside(const FGeoBoundingBox& Other) const { return (IsInside(Other.MinLocation) && IsInside(Other.MaxLocation)); } FGeoPosition GetCenter() const; FGeoCorners ToCorners() const; double GetDeltaLongitude() const { return MaxLocation.Longitude - MinLocation.Longitude; } double GetDeltaLatitude() const { return MaxLocation.Latitude - MinLocation.Latitude; } };代码含义
02-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值