diff --git a/entry/src/main/ets/pages/DownsamplingPage.ets b/entry/src/main/ets/pages/DownsamplingPage.ets index de21508..7215f85 100644 --- a/entry/src/main/ets/pages/DownsamplingPage.ets +++ b/entry/src/main/ets/pages/DownsamplingPage.ets @@ -12,41 +12,31 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { RequestOption, ImageKnifeGlobal, ImageKnifeOption, ImageKnifeComponent } from '@ohos/libraryimageknife' +import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/libraryimageknife' import { BusinessError } from '@ohos.base' -import { ImageKnifeData } from '@ohos/libraryimageknife' -import { - DownsampleNone, - FitCenter -} from '@ohos/imageknife/src/main/ets/components/inageknife/Downsampling/Downsamplestartegy' - -// PixelMap transform示例 let mRotate: number = 0; -//let mUrl= "https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVqqB" let murl = $r('app.media.pngSample'); let setting = new DownsampleNone() let mUrl = $r('app.media.pngSample'); -let setting = new DownsampleNone() - @Entry @Component struct DownsamplingPage { @State url: string = ""; @State mCropPixelMap?: PixelMap = undefined; - @state mRoundPixelMap?: PixelMap = undefined; + @State mRoundPixelMap?: PixelMap = undefined; @State mCirclePixelMap?: PixelMap = undefined; @State mCircleBorderPixelMap?: PixelMap = undefined; - @state mRotatePixelMap?: PixelMap = undefined; - @state mSquarePixelMap?: PixelMap = undefined; - @state mSquarePixelMap1?: PixelMap = undefined; - @state mClipCenterPixelMap?: PixelMap = undefined; - @state mClipBottomPixelMap?: PixelMap = undefined; - @state mGrayscalePixelMap?: PixelMap = undefined; - @state mBrightnessPixelMap?: PixelMap = undefined; + @State mRotatePixelMap?: PixelMap = undefined; + @State mSquarePixelMap?: PixelMap = undefined; + @State mSquarePixelMap1?: PixelMap = undefined; + @State mClipCenterPixelMap?: PixelMap = undefined; + @State mClipBottomPixelMap?: PixelMap = undefined; + @State mGrayscalePixelMap?: PixelMap = undefined; + @State mBrightnessPixelMap?: PixelMap = undefined; @State mContrastPixelMap?: PixelMap = undefined; - @state mInvertPixelMap?: PixelMap = undefined; - @state mSepiaPixelMap?: PixelMap = undefined; + @State mInvertPixelMap?: PixelMap = undefined; + @State mSepiaPixelMap?: PixelMap = undefined; @State mSketchPixelMap?: PixelMap = undefined; - @state mBlurPixelMap?: PixelMap = undefined; - @state mPixelPixelMap?: PixelMap = undefined; + @State mBlurPixelMap?: PixelMap = undefined; + @State mPixelPixelMap?: PixelMap = undefined; @State mSwirlPixelMap?: PixelMap = undefined; @State mMaskPixelMap?: PixelMap = undefined; @State mKuwaharaPixelMap?: PixelMap = undefined; @@ -54,7 +44,7 @@ struct DownsamplingPage { @State mVignettePixelMap?: PixelMap = undefined; @State BytesNumber: number = 0; @State BytesNumber1: number = 0; - @state imageKnifeOption2: ImageKnifeOption = + @State imageKnifeOption2: ImageKnifeOption = { loadSrc: $r('app.media.gifSample'), placeholderSrc: $r('app.media.icon_loading'), @@ -74,7 +64,7 @@ struct DownsamplingPage { .height(35) .width(120) .margin({ top: 10 }) - .onclick(() => { + .onClick(() => { this.transformSquare(); }); if (this.mSquarePixelMap) { @@ -90,7 +80,7 @@ struct DownsamplingPage { Column() { Text("大小:" + this.BytesNumber1).fontColor(Color.Gray).fontSize(16); Button() { - Text('降采样').fontsize(13).fontColor(Color.White) + Text('降采样').fontSize(13).fontColor(Color.White) } .height(35).width(120) .margin({ top: 10 }) @@ -107,7 +97,7 @@ struct DownsamplingPage { }.margin({ top: 10 }); }.margin({ bottom: 30 }); Column() { - column() { + Column() { Text("ImageKnifeComponent用法").fontColor(Color.Gray).fontSize(16); ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption2 }) .width(200) @@ -121,7 +111,7 @@ struct DownsamplingPage { //正方形裁剪 transformSquare() { let imageKnifeOption = new RequestOption(); - imageKnifeOption.load(murl) + imageKnifeOption.load(mUrl) .addListener({ callback: (err: BusinessError | string, data: ImageKnifeData) => { this.mSquarePixelMap = data.drawPixelMap?.imagePixelMap as PixelMap; this.BytesNumber = (data.drawPixelMap?.imagePixelMap as PixelMap).getPixelBytesNumber()