# ohos-combination-avatar **Repository Path**: HarmonyOS-tpc/ohos-combination-avatar ## Basic Information - **Project Name**: ohos-combination-avatar - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-09-17 - **Last Updated**: 2023-04-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ohos_combination_avatar ohos_combination_avatar: An openharmony library to convert the Pixelmap image to combination of avtara image. ## ohos_combination_avatar includes: *combination avatar image library includes multiple image combined in single pixelimage like avtara ## Usage Instructions 1. A sample project which provides runnable code examples that demonstrate uses of the classes in this project is available in the sample/ folder. 2. The following core classes are the essential interface to ohos_combination_avatar: CircularImageView : this class basically we are creating the xnl layout for combination of avatara image. 3. The steps to initialize the ohos_combination_avatar and the core classes: private void initValues() { PixelMapElement avatar1 = ResUtil.getPixelMapDrawable(getContext(), ResourceTable.Media_headshow1); PixelMapElement avatar2 = ResUtil.getPixelMapDrawable(getContext(), ResourceTable.Media_headshow2); PixelMapElement avatar3 = ResUtil.getPixelMapDrawable(getContext(), ResourceTable.Media_headshow3); PixelMapElement avatar4 = ResUtil.getPixelMapDrawable(getContext(), ResourceTable.Media_headshow4); PixelMapElement avatar5 = ResUtil.getPixelMapDrawable(getContext(), ResourceTable.Media_headshow5); mBmps1.add(avatar1.getPixelMap()); mBmps2.add(avatar1.getPixelMap()); mBmps3.add(avatar1.getPixelMap()); mBmps4.add(avatar1.getPixelMap()); mBmps5.add(avatar1.getPixelMap()); mBmps2.add(avatar2.getPixelMap()); mBmps3.add(avatar2.getPixelMap()); mBmps4.add(avatar2.getPixelMap()); mBmps5.add(avatar2.getPixelMap()); mBmps3.add(avatar3.getPixelMap()); mBmps4.add(avatar3.getPixelMap()); mBmps5.add(avatar3.getPixelMap()); mBmps4.add(avatar4.getPixelMap()); mBmps5.add(avatar4.getPixelMap()); mBmps5.add(avatar5.getPixelMap()); mImageView1 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView1); mImageView2 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView2); mImageView3 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView3); mImageView4 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView4); mImageView5 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView5); mImageView1.setImageBitmaps(mBmps1); mImageView2.setImageBitmaps(mBmps2); mImageView3.setImageBitmaps(mBmps3); mImageView4.setImageBitmaps(mBmps4); mImageView5.setImageBitmaps(mBmps5); setValues(); } private void setValues() { CircularImageView mImageView21 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView21); CircularImageView mImageView22 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView22); CircularImageView mImageView23 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView23); CircularImageView mImageView24 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView24); CircularImageView mImageView25 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView25); mImageView21.setImageBitmaps(mBmps1); mImageView22.setImageBitmaps(mBmps2); mImageView23.setImageBitmaps(mBmps3); mImageView24.setImageBitmaps(mBmps4); mImageView25.setImageBitmaps(mBmps5); CircularImageView mImageView31 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView31); CircularImageView mImageView32 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView32); CircularImageView mImageView33 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView33); CircularImageView mImageView34 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView34); CircularImageView mImageView35 = (CircularImageView) findComponentById(ResourceTable.Id_circularImageView35); mImageView31.setImageBitmaps(mBmps1); mImageView32.setImageBitmaps(mBmps2); mImageView33.setImageBitmaps(mBmps3); mImageView34.setImageBitmaps(mBmps4); mImageView35.setImageBitmaps(mBmps5); @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (hasFocus) { mImageView1.setPixelMap(JoinBitmaps.createBitmap(mImageView1.getWidth(), mImageView1.getHeight(), mBmps)); int count = Math.min(mBmps.size(), JoinLayout.max()); float[] size2 = size2(count); mImageView2.setPixelMap(JoinBitmaps.createBitmap(mImageView2.getWidth(), mImageView2.getHeight(), mBmps, count, size2)); float[] size3 = size3(count); mImageView3.setPixelMap(JoinBitmaps.createBitmap(mImageView3.getWidth(), mImageView3.getHeight(), mBmps, count, size3)); mImageView4.setPixelMap(JoinBitmaps.createBitmap(mImageView4.getWidth(), mImageView4.getHeight(), mBmps, count, size2, 0.3f)); } } private static final float[][] sizes3 = {new float[]{0.9f, 0.9f}, new float[]{0.5f, 0.65f}, new float[]{0.45f, 0.9f}, new float[]{0.45f, 0.91f}, new float[]{0.38f, 0.80f}}; /** * size3 * * @param count integer * @return value */ public static float[] size3(int count) { return count > 0 && count <= sizes3.length ? sizes3[count - 1] : null; } private static final float[][] sizes2 = {new float[]{0.9f, 0.9f}, new float[]{0.5f, 0.65f}, new float[]{0.35f, 0.8f}, new float[]{0.45f, 0.91f}, new float[]{0.38f, 0.80f}}; /** * size2 * * @param count integer * @return count */ public static float[] size2(int count) { return count > 0 && count <= sizes2.length ? sizes2[count - 1] : null; } ## Installation instruction 1.For using module in sample app,include the below library dependency to generate hap/ohos_circular_avatar.har: Add the dependencies in entry/build.gradle as below : dependencies { implementation project(path: ':ohos_combination_avatar') } 2. Using the ohos_combination_avatar har, make sure to add ohos_circular_avatar.har file in the entry/libs folder and add the below dependency in build.gradle. Modify the dependencies in the entry/build.gradle file. dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) } ## License Copyright (c) 2014 Kong Nan Licensed under the Apache License, Version 2.0