I'm creating an application for placing one image view on the another image view and made to single image and save into SD card. I run the application it creates image and save to SD card but this image is blank. Both images are not showing on one single image which is save in the SD card.
Here is my code.
#SuppressWarnings("deprecation")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ImageView image2 = (ImageView) findViewById(R.id.ImageViewTwo);
final ImageView image = (ImageView) findViewById(R.id.ImageViewOne);
mTempDir = Environment.getExternalStorageDirectory()+"/"+"TestTemp";
File mtempFile = new File(mTempDir);
if(!mtempFile.exists())
{
mtempFile.mkdir();
}
mSaveImageName = "Test.png";
mBackGround = Bitmap.createBitmap(100 , 100 ,Bitmap.Config.ARGB_8888);
image2.buildDrawingCache();
mBackImage = image2.getDrawingCache();
mBackImage = Bitmap.createBitmap(100 , 100 ,Bitmap.Config.ARGB_8888);
image.buildDrawingCache();
mTopImage = image.getDrawingCache();
mTopImage = Bitmap.createBitmap(100 , 100 , Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(mBackGround);
//mCanvas.drawBitmap(mBackImage, (mCanvas.getWidth() / 2), 0, null);
mCanvas.drawBitmap(mBackImage ,0f , 0f , null);
mCanvas.drawBitmap(mTopImage, 12f , 12f , null);
try
{
mBitmapDrawable = new BitmapDrawable(mBackGround);
Bitmap mNewSaving = mBitmapDrawable .getBitmap();
String ftoSave = mTempDir + mSaveImageName;
File mFile = new File(ftoSave);
mFileOutputStream = new FileOutputStream(mFile);
mNewSaving.compress(CompressFormat.PNG, 95 , mFileOutputStream);
mFileOutputStream.flush();
mFileOutputStream.close();
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.i(TAG, "Image Created");
}
You have a few excess lines:
image2.buildDrawingCache();
mBackImage = image2.getDrawingCache();
// delete next line
mBackImage = Bitmap.createBitmap(100 , 100 ,Bitmap.Config.ARGB_8888);
image.buildDrawingCache();
mTopImage = image.getDrawingCache();
// delete next line
mTopImage = Bitmap.createBitmap(100 , 100 , Bitmap.Config.ARGB_8888);
Related
What I want to do:
When user takes a picture, I want to add custom text at the bottom of this picture
What I've tried:
I assume that I have to do 4 things in order for this to work
1. Create bitmap background eg. photo thas has been taken
private Bitmap createBitmapFromJpg(Uri mPhotoUri) throws FileNotFoundException {
File f = new File(mPhotoUri.getPath());
return BitmapFactory.decodeStream(new FileInputStream(f));
}
2. Create foreground to put on the background
Here I have error that says java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.Bitmap android.widget.EditText.getDrawingCache()' on a null object reference
private Bitmap createBitmapToDrawOnPicture(Context context) {
LinearLayout linearLayout = new LinearLayout(context);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
linearLayout.setOrientation(LinearLayout.VERTICAL);
layoutParams.setMargins(2, 1, 2, 1);
linearLayout.setLayoutParams(layoutParams);
EditText editText = new EditText (context);
editText.setTextSize(15);
editText.setLayoutParams(layoutParams);
linearLayout.setGravity(Gravity.CENTER);
editText.setText("testtesttesttest");
linearLayout.addView(editText);
editText.setCursorVisible(false);
editText.buildDrawingCache();
return Bitmap.createBitmap(mEditText.getDrawingCache());
}
3. Merging both Bitmaps
private Bitmap mergeBitmapsAndConvert(Bitmap foreground, Bitmap background) {
Bitmap finalBitmap = Bitmap.createBitmap(background.getWidth(), background.getHeight(), background.getConfig());
Canvas canvas = new Canvas(finalBitmap);
canvas.drawBitmap(background, new Matrix(), null);
canvas.drawBitmap(foreground, new Matrix(),null);
return finalBitmap;
}
4. Convert from bitmap to jpg
private void convertToJpeg(Bitmap bitmap, Uri path) {
File file = new File(path.getPath());
try {
FileOutputStream out = new FileOutputStream(file);
if (bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out)) {
out.flush();
out.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
I have an image (1.84MB) to load and I want to load a smaller version of it to gain time, I also don't want to store a smaller version of it. For info, these files are located in a removable SD card, and I need to load a lot, thats why I want to optimize it, as it takes too much time for the moment...
I red the load large bitmaps documentation. I previously used Glide to load the full image.
After some test, I get this statistics:
Glide load (1.84MB): 244'361'667 ns
Bitmap load (scale 1): 370'811'511 ns
Bitmap load (scale 4): 324'403'386 ns
Bitmap load (scale 8): 269'223'073 ns
Thumbnail load: 245'250'729 ns
Which means I get a slightly longer time with Bitmap while loading a 8 times smaller image, and I don't get why.
Here is my code:
load with glide:
private void loadGlide(Car c) {
DocumentFile makerDir = contentDirectory.findFile(getMakerById(c.getMakerId()).getName());
DocumentFile carPhoto = makerDir.findFile(c.getFilename());
if(carPhoto == null) {
Log.d("test", c.getFilename() + " problem");
} else {
Log.d("test", carPhoto.exists() + "");
}
ImageView img = new ImageView(this);
img.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
goToEdit(c.getId());
}
});
// standard loading
Glide.with(img.getContext()).load(carPhoto.getUri()).into(img);
resultList.addView(img);
}
load with bitmap:
private void scaledLoad(Car c, int scale) {
DocumentFile makerDir = contentDirectory.findFile(getMakerById(c.getMakerId()).getName());
DocumentFile carPhoto = makerDir.findFile(c.getFilename());
Bitmap b = null;
//Decode image size
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = scale;
// convert DocumentFile to File
File image = new File("image_path");
FileInputStream fis = null;
try {
fis = new FileInputStream(image);
b = BitmapFactory.decodeStream(fis, null, options);
fis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if(b != null) {
ImageView img = new ImageView(this);
img.setImageBitmap(b);
resultList.addView(img);
}
}
I also tried to load thumbnails:
private void loadThumbnail() {
Bitmap ThumbImage = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile("filepath"),
816, 612);
ImageView img = new ImageView(this);
img.setImageBitmap(ThumbImage);
resultList.addView(img);
}
And here is the test code if you want:
long t0 = System.nanoTime();
scaledLoad(c, 1);
// or
loadGlide(c);
long t1 = System.nanoTime();
t1 = (t1-t0);
Log.d("test", "t1:" + t1);
If you can answer me or give me any other alternative to load underscaled images from SD card FAST, you are welcome. Thanks in advance.
If you are using Glide you can use the function "override(width,height)" to load resized image into the imageView.
This blogs explains how to do it : https://futurestud.io/tutorials/glide-image-resizing-scaling#imageresizingwithoverridexy
Im using xamarin with c#. I'm trying this code for preview an image from sql server into an imageview.
ImageView imageView = FindViewById<ImageView>(Resource.Id.lk);
Button btn = FindViewById<Button>(Resource.Id.btnsd);
btn.Click += delegate
{
con.Open();
SqlDataAdapter dataAdapter = new SqlDataAdapter(new SqlCommand("SELECT map fROM deliveryadress where deliveryid=2", con));
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
if (dataSet.Tables[0].Rows.Count == 1)
{
System.Byte[] data = new System.Byte[0];
data = (System.Byte[])(dataSet.Tables[0].Rows[0]["map"]);
MemoryStream mem = new MemoryStream(data);
imageView = Image.FromStream(mem);
};
But i'm getting error in 'Image.FromStream(mem)'.
If i will include Android.Media then i'm getting error in FromStream that image does not contain definition for FromStream.
Also i tried another aproach but i get FactoryReturned null:
ImageView imageView = FindViewById<ImageView>(Resource.Id.lk);
Button gg = FindViewById<Button>(Resource.Id.btnsd);
gg.Click += delegate
{
string myBytes = "0xFFD8FFE000104A46494600010100000100010000FFDB0084000906071313121513121316161517191D19181818181A1A1E1A1B181A18181B1D1A18201D2820181A251E171A22312226292B2E2E2E1D1F3338332D37282D2E2B010A0A0A0E0D0E1A10101B2D2520252D2D2D2B2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2D2B2D2D2D2D2DFFC000110800C2010403012200021101031101FFC4001C0000020301010101000000000000000000040502030600010708FFC4004110000103020502040403060404070100000102031100210405123141516106132271328191B142A1C1142352D1E1F0076272F11533B2C21624435382839234FFC4001A010003010101010000000000000000000001020300040506FFC4002911000202010303040202030000000000000001021103122131042241133251611491427133A1E1FFDA000C03010002110311003F00C63485CC13EA3C0B7D2D4D5FCA0368538A7529DCA85C8B4DA07C440DFDAB3EC392E7437B6FABA6F47B8DE85C6A27F109D8CA636F9ABE75C721D34B6399C5A48D24DE2C620F5EB3B702B4395E01B7F5AD6A4C263D207A8CD89526C09E9BD6650DEA2141204103AFA78A7780C402E449404C10A1066F004454E6A96C05EE1E60C804A4B8A4A3F08249524051483090484820CF22BDCD9682086FF78E254095001091E9584C73333EFCEC298A72E4928506F42D6A4A67494A49102D23D3209053B1333BD06EE5451ADE7D0B4262C3D26E200D3623F10B815CF1A3AFEC9E03C2CAC400A5C2D4012404AB4031F09598D4798D8C44D0AEE1DEF2FCB43C801A7028B7A93162AD52900131FC247704CD6ABC018C5BA97149674B6DEA4C02415AC913B9D262FC0AC178EF0A19C46CA4ADC56B5444816E413332677D855DE354A82DC66FBB73479361DA7F1000584B89E569904442826F0913C7735AAC2F8753856824AF52B52944C40F510634ED15F28CA33F71B7421495127722CA226489D88B0AFA51F12318941F2CAAC20829223E7B7E1350CAAB1355BF82EB4CA49C1EDE4C663BC31880E38B484AD2A320823692A82991EA93CD2BC46095E583035F448D446912A0601095089F91A69973588714E38DA54A6D2ADF5148DE2C6F7045EB57E06C3A5C0F61DC4A12084AD1A49D66642D527B148B7534D825ADA8F9427538D6366370397B6B425C5A14F926014AC8FA880AD56A7F94E052EB659FD95686D3750716A85491789F51B1304702F4B7C57949C32DE630EF6B010870370BD69D266D034AAD1CCDEB34BCE1DFD9E43AEA06A3F093A89D8EABF6B5094327F1608E5C71824E3BFC9A5CCB2043082B1094A64C249207B1D22E6958C4E07420A8B922663926F04FE548CE66E38DA5A5AD6B337254761B022609A0B1D8070AE120A926142FD40DFA0E6FD6AD0C4F89BFD1D193AA4A29A3519DF8DDA529270814D3A949405842608205951F16D131D687C3F895D5A82C81A840F48D311D3B566F0B97980AD8C7276333FDFBD32CB308520A9529484AA0C1F5A8260049E7D4455258E2274D9E76F636991E74853BA4B20296080A44852967AA7E13EF6A7B98E096D80B7040D5A5401BC9DABE727397B0C7CC6400B07E22248EA056A724CF0BBA5ECC16B52956650107413206B00082648F8AB9B374EE55A5D1579F44BB52AF81A6130DE62E144C2783723983F2A76EE75E436A8B686F4A0DA01DC957D0528C63FE4BCB84A89734CE905507D86DBFE553C4B2A7E10B65D28D8A4208D43A131226965789ED60935955B116599FB4F624024871C241D3B1FEBEF5B4CE73540FDCB4674C6B3EDB26791403FE1A650AF370F84F29C29D255A484A4004CC75EF5F2DCF7C48EB4BD2CAE146E5563BF49DFADA9F1B72F6A6BFB272945D3970BC1F49CD733F37579C9F300429222004157E2BF368A55FE19679FB331886D7A943CD504806E902526DC440AC760F327F12B46A243600D7680B54F51DEB58CA90310DF99012A52F5C4012B42E27B498F9D3DCF1F266A1923491663BC66AC32036101487140B8E47A96098503C49037E86ACF10F8F595A7CAC335A92A1EAD6DEFDE267B49A2338F07B6B415B4E796D0B695FA848DC9278E97A4CF7845D794E398658218421B484EEE2A06A8E098068A9EA6D3E49E88ADFC0B72B7710E1484B81A41FFD253850889BFA098BCCD57E2DF0AB4870BB86712E3204426FE59FB91DC54D8C0CC17167F8749F8CABB27840DA55EF41E29294BA96941D490925506473168F48B568B690F9BD27C3138C1A0A105406A2A8930075DC73028F7BC3DA594ADDDCAB537063D009267B40B76AD0E439038B01D40438D948F4AC88842A4E941373DCC52CCE716E2DD5B708484CC094480A1A529241E269DCDBE0E54A11DD8AB2F29D376DB37E77D876AEABC34F360265A1698D4D93727721444D756A62A71AF279E6A6C8B192208926DBFB5762EE6003791F23D0F1266F5071015E949889207E5C1EF43A312663512782277BC4FE547490690CF0B804AA54A2529034C4ED1C4F3BD118C798C3A46948267D33799179E29662C5B7249D80BEDCFBD4B0050523CD320DF4ABB7F58AD567441248D47853165D502A56A48F5D8C1945C46E12014ED69A3B1EEEA65C0B7DB524005252B21C99B9524A60446D14872FC780A96E12408F4C0B74279DF6322A580530E0714B2AD44694A881F1289D4ADFD20FEA2B9E78B4B6C34D3186033975A48C3B0A296552E6A046AB824CA808BC1B7614AF3B52DC212BBAB4A54932490553FBBF7238EE29F2B06970210BF8C2094A424247A40EE265449A518A79CF392958095A470902E64A493CC9293FFC68C65A9A1BD64B667987CB14E16CB0D7AD6895028981AD29054AD8CC9BDA239AD3B996E1B0651FB4AD6B58480A69311793EA3B90260446D5A6F00E210E61617E58500010903D284984C9E6F348BC485CC43CA4220A10A0224588EA62408BCCD1C9DB00F4E939D3E0CDE61E2274BD2D00DA52210802C11C48D8D4F2B427CC46214E2905B0648309D241B08129BC75DA99B1E115AD4216D295791E65C7411B9FA533CBF28186528629A41429260AA1490A0253F6DA2A58E1BEA3B324E0952DCF9AA7C55896B1EEBCCACFA890357ABD1B091EC99B4533CDF3371C4853ECB6CAC09D7A0A4A8ABF12C6CAF945159E21C71255876821B5C174008484AC12094FE2524C4F1BD0F9032A0F256F10EA63410EA94AB0B881324445A7B574B6A472B9452762DC7600A34AB8706AD4044EF1142ADC4490012B09BC13757C5A4002F5BEF15E6CCE2184A435E52D80148002408242480264263B7CAA3E1EF0C38ECABC9204479ABF40237948F895BD65F0724934B731F8B614D25B714D6B4C989B27D2120898BDE8BCB5EFDB94DA5E2FBAE24684A184261009112764003AFD6BEACC787B0CD34D32A1E6689804C05289D4A57CF555AE66294221B421B4FF000A623E702ACB1DF25FD7A5B18D4FF879215A9EF2E240D494937992405EF048E2B4793E5383C3A21B6C3AE45DC22556223990046D341E2312B264851F7D87B4ED516B30500626793C9BD3C6091194DC9DB342ACEE12084807AC6FBFF2AA5FCED42F359F79B51D81D8481ED3F7AAFCE3B1BCFF007CD308681BCD14B044EF58EF16E56D04A9E6F0E143771A022DFC688D95D63E94CD0F1B0B08A21C775A4471F089933DFEA28343C6547CFF00C380625C790079684340B680775090207F113C55AE61DD7582969216E01A548528255D098544EFF5A233AF0D9F30E270D295594A48B5C7E249EB2299F85738562318CF9E86D6B04EA714003A4255B8D8ABA1AE69A699DB8DF6B68579378ADE610AC1E3C2921C0520AD2429330248206A16DC7F5AD5F85733FD90A92E254A41BA1500881374906F68B40DCDEB479DE1D4A4ACB81971A293A526DA604C8917577AF8B3F8D7F0A96F5AC852B5424127D000851E01278A56EA5DA08454E3B9AAC2A70D8879CC4F9A5A756E9504990122D090623704DFDB6ABFC5397A50E92DA41F387E01BAA06A3DB698046E6B2997BE1D5A442754C9526C6DC91B098DC56B4A16946A752A4A4C9826DA79857715C99E738CED7074C7A6C7923562FCADCC4B7875A1A64260E975455A4A6360A1C0E6DB98A01CC19504EA5235A60CA52522C66D37513B5E3F4AD6E66E36E6242F50425C4CAD445804A6FAA6C7615EB68C99707F6A4A94770DAFFED13157A72DE249471423A668C13F2D1D05CD247637EF7DABA8BF10350F2861D4A537FC4A00EA3C9B898AF69B57D9CB2E9E57B27FA12E10C2C85206AB948D88048B5B8ED5279930A710848700B8D858E9B77DAD55C2C0F3014EF015B4CF5EDCD15806C6AF2F54F989295951F8490AE3A0849ABAE6CE77B16AF0DFBC328F4801524F31F6927E8295E31CB2922C426E019206FF00CBEB45BAB25474C056C53723B42B922FF5AAB05966A5DA66E0952800131B9EB41721726DA48A70595ADC52C242896F8482A84C76E7A568F274BA55E5B4848255EAD605A2237220983691BD31CBD12CA9186734292A4952BF888130A81F0916A0B304E8C51C40700D3A75055E091E981D0D4E4D49D1D1E8B54D9AE5F86710D214B537E6085909D684C6A1375923426D700DFAD64F198050FDEC05909014849D699BE912951848D3713B0DF787B89CF7118B6B52DC01A16525B4A89300DC81D48005E248A4CD63FE00891A4993B15289DE06DE9004717A976A7DA0C7814B66CA721C596FCE5A97E525490927D47D3AAC74A7E2173DB6A639DE94B29FD9DF71442B512A0125C2A1A75003809157B7999D3A54949448374A41B77E4EF6DAF4A587438B5252A096C12527495124090911CD096E553585D317685A51A9AD5E68BAB4985093A42A781CD6C3C59E2B2B3E4EB4C40300CC807926C0CD669CCA9D2429674A4996D69E74CC83CDEC229C787BC28E3EB054849481256A10904998107D71D29A2B56D1127D426F819E5190A5ED052E2DB2A009B5C800024245A7DF793BD30C6FF87CD9521C69F5B602893AC49266C6200DFB0AD6E579536CA45F52C0F8880227A01B52FC6E24A965324C574E2C0A2B739F264B97694E5B96E15856A00B8EE909F3570A2600811B26C3A512F666770604C7BCF6E94A0367511B74207DE99A7089DA640027EBD7A55D2AE04B010EA94A0493FD81C559FB119DCF583CD36461DA9246F6060CED3FEDF3A1319A0581F513B1B6D737A20B11668EC2804024F4BC4FE86AE672679C20ACE881CFC5F41B53BC8168735382DA61205AC22EA1D6769ACCFF0089B99E3186D070FE86D44871604A81E0FF00941EB5A8D6357B29D292039A8FCC091D4D21C43AB412958D3CFBF79E6B1BE1CF136230EE6B2B53C153A90B5154D8C40E0CC56AF2BC4E618C752B7990D3005ADA63A1BFA8FB08146999326D3A9D8922F7B0DAA4B76F293B1B51199605283F100AE8040F7A00D8DEDF6A4686084EB3F7BC52BCF9B71B654BC2B682A12B7004FA943920FF00DBF3A6C87A529006C49917F880B7B08FCCD10011C192391BF3F7A4618CE51E0F9AE37C6B8E76CE39291F8760204081D40A7F8DCC11E787B4C9424413789481041B47BD5FE24F0D3789254DFA16A242D3B0518891D15602846FC098D2E153C52D369015733ABB27A1F7A864C69EE8ECE9F224A9F010D2F0AEACC309617A490A6814EB57B6C998DC5F7A87883C54AC4B4867CB0DE1D3E954056A0A00C7A89103DE66897B06CEA8523540B5E0CC751B4564B079B36D3A50F254E241928930A3B26482262F48AFFB3A6A1B5ED43F6713FB56117855C974DD1A5444A12A485DF655A647D2F14BB19E1958F252CA510900A882AD6E2B724C81A44DA05A0569B38C6338CCB83CDE84BADA804250928D126C9278491373DAB2B86771B85774B8E2A14614112B294106C551B5EF41A95D45D2F8346516B5496E3C4E5AA50056B4A4ED135D4931B94B6B5923DA045A2DF2AEA8FA33F9FF0047A1F94FE5FEFF00E15E1B06A4A4E94A973B0DFF00CDF2E97AAF2AC02D788485242654536E354893D6C6BC6F1650530482A50049E64FF0EE07141E2DE77CC50429448234E9DE64A60753B0AEC8B76CF9A838BF70C714DB494A5B851702D40B80C0D33681CAA23F9D4F28CA541E1E61052B4A93AA499E53222C640FCEA39A61DE4A51E62616522645E06E7DE9BF853C34F798D623F690B66EAD3041DB620D2B7476FA70D9A1961F1ECE119536E00957E29104F433CDB689F9562B36CDFCE2A286C4101226C4C4A89EB02C2BEAB8ECB19C414F9CDA5CD26533C7F4ED5F34CFB04A38F5A1A123D300080991B74D82AA7892BB2992764FC3B9E292129164EA137E1408FC899FA519886FCC796E6B2098326008178483606791573390B0D00525733732082666222A79FF00879694B4EB2B735830102146FB1803698A351D56727A534F5201C16AC47EE90A4F99ABD2153B264AA606D2001D6BEA7E1EF0920E1929C4B69F3149831B0133E9E8639FB561BC3D9162313885388479202402E70143720F2A99AFAB623304B28D2A256A09BF5F78E2AB0C5DD6F83669524EF714A7C32CE1E06B5ADA164B4A821327F8B7236FA5598BCCA0402137D80B0E961EF4ADDCC14BF4F1BC9B7D279A8A136956C3FBBD74462A3C1CD63D6F1FB6A904EDEDDA85C5BC0904823DE44FE55E3387484A56812A9D8AA6DB1827B1DAA19AAB403E9528F0811C5E678A731521D0B714942093BC5FEA4D86F4C99C1CD967B103DB624DE3F2EF5665B8A6D4D8535F02BEA0FF000AB90AED5F2CF1E63F30F3CB2EB850D13FBB0D4A52A4F73BA955807D34609047EED440E0A55227B89EF4A31F8853728713EB170771EE3DC5A967F87395BEC2165C9425C034A0EF20FC507E117883BDAACF1AE74DA5FC3B048D449D51B8491E92AE9264FCAB05136F1CA0A0B6C84C71C01D08E94FB0F8B4625A57A67875044DC8EFB8E66B2EA4011BC11F5AE7C3ECA462190A0A0403ABE158E411FAD03113E1DFD8CF9AC266E082A136932888B5A63EF5D93788F1B88C400AC304B170A90A0474327EC2A6C7F89386274BC85B6A1BFA7509BEDDAF4B738FF145B074B2C973BAFD03FF00CEF1EC051A60D8D9E6B876D68852A0CC2546D27FBE29261731C233AC62000A44FA8C90AF6AF9766F9C62316AD4FAE6F21204253EC3F5A639261FCD4F90E03A0DD260D8EFF171D6B51ACD323326DD2A561D44B615F8847E5331D28B6B1D3B993B6E6B3D81C91C65C252A4A93B1BCC8E36E94F18C3FF006296511931824C8B264F3D4D7B9B3AFBACE94AA747AA0EE427A75B1DBDAA796B73B98E413CEF4EB0780F4C8827B713371D8D49C1B1A1370767CE179929C4A9E827F88849012027DADB452BF0FF0084578F2FADB311A74CEC4DF51F613C75AFA5E2B214294B052A2D2D492E369546B8105422F2245BB5687C3F94E170656869446A8252A54E9E2C389A9A8B4F73AE79D38AD2B73E3DFF0087B1AC8750965DD3212BD29B28A495209DE40267E54C704979950742B50D1A5C6D493703AAFAFCABEBF89C4E942E24284EFF00383DE91672CB4CE853841F306958540B1F895D88B45AA735BDA343337DAFC990CA19CB9E415AD0CB6AD4652E2413300C83C8BD7527C664983716A21F20031022D15D54521F4C8A3FE1C924809850880A898E2E36F7A6583C8F0FA9B5AFCC4BA0A482142E419162237A03390A69E0A4AA245927691BC0DC50B9A7880A747A6E9065523A58F515C78DE58E4F94567084E3746EB1EC3189490B095E9904CDC11737E280C9192CAC210E0532A9212A225263706D63B5EBE5EDE70E869C6D2A5042A75099267754F536BD3BF07B23CB712B3A92A22CABC01B08368AEAC91B56CE58CAE5A0FA4623306DA054A58E82E2E78BF4AF9BAF34752EB8EA162146608DC0B7E9F9D685861B08284A426FB0D8FB8E6A8561527D30922604804826D02D52C551659C5A41992FED6B21C296834BD0A83710A89B0120DE7E75B4C2653B38F13A774A7957BF415E64997A5869AF36EB4A13FBBDF49090255DED5E63B10A5112B1067AE9F9D742C49BB6467D43E204B1B9BA927423D205C6988F98E696BAF4C9511A8DEE7816BFB74A8246A0A26FB277DB7E6827936302D6FC5700DBF3AE9FA38DBDEC65845050D1A4AAF75023ED46B4952D612980122E551D444DE6D4B5189B274889B6C37178EA6D155E62C2912FB5AC3C932249F54EE98E9FCA898D2E6045950346CA30644DA446C9AE52F5C90349110645FDBB54323CD10FB41698136527783B1045433268221449D04DB913D23F5AC615AD4E61567108054C288F39023D27F893DC1DFAD6816A69496D7E9508D4826F654991D0D29C33CBD24252144D97D238F4F37A5785C6FEC8EE8583FB3B93A4FF00ED28F1D4249BC0A280C55E33F1DBCDB8A61968B4A1652D7137FE01B46D73585659595F98B5152D4664992499B93CD7D5FC65912714D6BF4A5C6A74B84D8A6274A8F4B5AB1F9461509485A8052BDE427B27AFBD1B40A1BE0DF7120198584C03BF7DA83CF3C76EE8F252C8D4530B52A6C79D207B0335687E040091F99A1F1F9725D4000E9501F171FEF7A50803597A312D859842D5793B4ED06871E0F7E7D21040E428453CCAB2A0DA084AF5A899E83BC0E4DA9934929D8FCBB9AD7F06A1060FC29A482EA81BEC916FAD3A561F4084C8044103BD35C2E1966C06F6E0FDE89C7E15B693A9D525007F11BCC1DA0748A035091B6CC6D6FB532C3E08AC4A13B5A3D86F3C03DE92E61E3265B0A461DAD7790B5D84FF00A7722B3999F88712F402E29223E1412911DC0E077A0DD18FA1E231D86646A7DC403D130A3B1D803334A1EF1EA026186564DC4ABD300D85BB457CFE2537933F3AF1D54D2EA30DB34F19631729F3021277094812477A965DE3071B5B4876ED1711A893C48D449DCC6F481F489DE9B23098255D6545506C544006DC44D73F5135B59E87438F56A48D9E6DFE226102CF94F1500608283A483CA083B89E6295E33C7B8652D6EA90F3CA29D2941010916DF55C81F2AC66271D8410DA5B920FA971B8DA200FCE9A6172D4BED2DC4090831E9B9FA45225F43AC714F4DEE858CE66E7A88682815122E4D8F13CFBD757794B4DA23B199AF6A9A415F6683C4F810FB652010527D244C823BF4ACA30F882D62019880A1BA4F3FEAAD16679CFA5296D527754521CC10140AD5681B8EFD7AD087C315C5A5A9142B01E5CA7E29363B883CFBD33CB9872240849E36F99ABF2365B5B63CA0B94887013AA4F053D011C714CB0A8D674CE902649130076A1393E07C708AEEF257916054EBBA10BD244150D460FD37AFA6649E134B0AF39675BC45A40D2DF531C93D78ACDF8732E698507F5151161609B189B5E662B518CCCC3B05B27D5330636311EF6154C2A2DDF921D4CE549205CC1DB9822771DCCC107BDE973C64C6A111D41DFDAA4E2A6C2CA303573363C401D3EB42BA2C07E109BC123D4A931DC0B57451C450B7140FA42943703A5EF31BD470EDA892544C03BCF1DA76AB1D5A64AD5A8DC92418DB61F4AA1D748B8DA640B7DBF5AC61961DC2D9104191707881C83B4834C1DC59300C1300983224ED7E978A42C28AB700916DFBCDFA915A0CBB00568495128898303D53B100EC3BD13085E695857462590742880EB7D524DC81C1DE0D6D1BC525D42569F536E0B1FE9C521C2E5EFA16A414EA4A8185488F9F4A648436C3113A50804924DAE493F9DA8F80317B799210E2838A2128594AC8FC8148BC445E86F1B669864B212A5A7598D291EA24133EA1B8490667E9599C9737F3F10FB841D0F28148FF48D2991C585E9278830212E92365727ED26F602B00AF3AC63CAD2DADC5A9A4FC009F4C7703E33BEF4CFC38E4A0A2DE9EBD2BCC061D2F3202C5C1B1A6B86C1A1B4FA763B9E7AD67C1BC910267EC28ACB9092B09262F13BF78A93185569241291B4D84CD3A7F02C3412A5AC21244CA89B76106E680C0981C27AF7548FCA4FA6DEE45159832C616EFBC012094C09263B71BD67F30F1A2AED60D1A522DE6ABE254741F845EB298D716B515AD454B3C9334B663599A78E9665384406D24DD6ABA8FB0D856531389538A25C5A94AFE25289F7EDBD54D77E3F3A9130262279A5B09E2C473EF5E2679F9FB74A8A46F1F9D70040B9FE958C4D4B150D306B946F7B55215CF7A561478EF414CFC51E14798646214F36750043409D50AB93D294A84FD68ACE5C0EBC0970AB4A1234CDAC26E7DE964D23A3045B7481300D210D7C014A26EB336117483B104DEA185C7BB8651718213ACDD13631DA7ED5734DADE5E96D173F403993B811DEBE9FE16F0DE0036D9C41438E9321A48D88B440BABAC9A9C53932F92518457C8A728C7BF886C3ADB2C849B428A810401360935ED7D6303814213A50D21B1FC200FCE39FAD753FA0C87E5FD1F9AF4262C209DE2A9CD02B401C28C7B532C261AC35DBF2FEE29A61F2F4EB485416C5D4AD43689EF7A1B2476F3B19E63351874A34AB4B82FA9222FD7BD3AFF8EFED4A4EB510B29F8662522E556DE4D5D8BF0BB4FAF5F9CAD0364848B0E9335562322670E0B8A756A8BEC12446D047A85F8A5938F0C92538BB5C10CE310EB3A034EAF52F8170909EDD4D68326C62D09417750D63D4542E95C1F501EF1594CD50BC3E29B75DF8549F489D858FA8F5BD68F0B98F9D2151298223A7F7155C4A99CF9DB95B35EF2B600182276DEC263A19B8A052C8DE23D374ED06FF008888D88FA50996628921A51954FEEE4D8E993A4CEFFCBDA8F641F5744F06D0153603A4F5BDABA0E50174A8CC5C7008EB6E076355051F86C0408EBED3576B5209E34F36BFB18B8AF5C44FFCCE403713311B72281825084E93EA57FAA4EDFD36EF55E5D9E2B0E34AC29C6CF3B94FB4F1DA83C53A480906DC46E64DAF5625C4F96A69513C759EB3D6F45018662BC6D85424E84BAB50B81E5E9BF751102B0D9FE6CF625614F1D280252D27E1027757F19A2B169D120820822DCF599A550B5AEC0993FDCF4A6A17908C02D5A90104EA9B476DC935A37F2F0A4CA824C9E4C9B5F6E2AACAB03A38F51104F4EC29EE1705E6286904F2A008B036B1277B52B19212B6C8D808E9D053BC1F87DC500B22DC8EDC1345E218C3E1015BEB804CA5047A8EF1FAD643C41E337B12AF2D12964D8205A47F98EFDE85847F9CF88B0F874E840F3DD17307D083D3A2A3B561735C7BD88505BEB2A3C03B01FE51B27E5515B60102C20FF662A2B3E9BCF6FEB4B662C4293C5A6AAC488162226BB0E2E62BB106C3A52D84F67A6F522AE761436B8F954BCCB5631E170DFDEBC42EA0B57351D758C49D2622A0950155A9C04D560D2B410A06E3DEA83A1A2AD647A8C01726E7703B54D0BA5C1E53CEA90A50492601E2075ED14B567463C8F1A75E4D67853235631D4A1A5A823FF51601000FD4D7D9F21CA98C310D61DB0348FDE390249E029712A5731C0AC47F873884A19202B43293EA5100ADC1C01C24133DED5F46631ACA56584292148405A9238492609F7834F8921334A4EAC5CDF8E303A9685BE9694DACA14973D2653C807717DEBCACFF0089BC0D81C63E5F579814A001D05601239B08DA2BAA9A909A11F2F632671642DF72E99809B0BEF7E3DEAD7D6A696991A90607713CCF22BC3E2B4A480E2409E97FB55599672821B5363502A008F9D72533BFD48D5A63CC6E3821041205F8FE7F4ACF6679B36EA4A090474FEBC9AB3326D4B580B1E88B721467F3D8D4B1D92611C09D2EADB501641823DA9638D5EE6C9927A7B4F315982F16D34CB900B6A84C45C109851E9144E4F80432B6D685856B2E244CCC2213F3F56AFA5220D900A64C8B13D00EFD688C1E24CA12494A47A011F10D5B991789249DB6A677CA6727AC9AA68D9296419B820DBDC6DF9D3F63148752547FE618040B5C1F528C5E0FEB485F4EA01C882A4826F326C0927933F7AB3018A2856B1EC4751C8AEC4ED1CC3D6848D0354004AC983E90240078DE97E331D104117000E6C3698EF460D4A6D4A6A4003D5A444851824CDE29063D4356D006C3F9F7AC63CF34933F4F6A3B00E44EA4A4FF00B8DBFAD2F41D881FAD138767A1E0EA3B6DBFE7F5AC1278B521CB9483DF73FDC55B81CBD1B20722C045BAF53B55296552239E60CF43EF4DB05864A4798B5696D22CB89FECEF6AC60AC364AB04289113EF02474DCC5059EF8ADBC2A56DE18A56EEC4F093C9EE62F149FC4BE2F2E0F2B0B286E0052A082BB7D522B35E5882209FD277A16622F62D6F9D6EA8951EBF992389AE6D379D86FEDDAB9298127D81EB5079522833052EE20FF7FD28570C0BF351F34C554B5DE804E0AF9D4D6BDEA9298AF41A0625AA399AE0ED0E555152E2B189ADC27BD56A51AA1CC444D561F2449B561945B2F0AA838E4550A7A06F55B0EA544A57304588E0F7ACF602415837C15428DBDE3E74DB29C9706F133895B6BE3523503DB857CEFED481586D4B4F41C6D4662710EA0A74B509047AAC62FBF6A0CAC2AAA8FA3786BC39886D6C69D2EB095A4ACA560024152C9D2A8503B6F4CB2D6F148C563710FA148F3123493710898320EC05EB0C7C581290015157304A41F9D4F26F1823CD50C4B6E2DBD2404A14419E3E5B8A92B3A3B56ED94E719B63705887586710B6D1ACAC2527D20B90A3A6761278AEA0B30CCDA755ABCA7540009054B9309B004E9E95D4DDC6BC65B8FCB7CBF5B8260E94A40BC7068218B61B3FBC64806F077EC666D715B2CF9F5B6DA54868AA5438F87DF9ACF6639329E525CC4292D24081B151FD054A0EF919D423491246608C404A53A12940848E8071346E2B21968AD0BD4A024FEB159DCCB0CC360796920A7F14DC9E09AAB0D983C0487B700111D44EF35451BE05796B6923D5B8ABA66C00E099FCE8D6F0AA2AD4091262F6FEEC6683C2FABE2223B8DFE60D3571403412AB10442E37E9F2A3238A6D290FB29C54301A54C236911093317FC556AC107B528C21D29D33EA90498171D3DAE23DA9CA17AD3FE64D88FD7E94F8DF8165CD8765589017A56A506D40C418851163FE99DFDC5505A24AD293E9499363683124CFCBDA8499041FEC6FFA532CA7122FAC052900940D3F1099FA8AB0A700520EA9B8B188E9623F0883BD30C0E0944EA0D9D0B302E6D078E48F7AAD8487120A894FA9572771E891DE0111352CC7356B0883ACF98B5240437DF727B0B0BF7A030C3337DA691AD4E80DA414817D424EC3AAA6BE7F9EE7AAC42A34E866004B7260EF750E0DEA8CD73279F5EA788DAC91B247403F5A1549BF1F2FE5CD2B6624D7BFF4AB16E01D7DEAB52A38FCE63DA877DC9BD031352CF78E95171555855AD35152C563120AAE4AAF5505715DAE80499354A966A3AAAA5BD468C494BE6867F103AD4C61D4E36A520FA93C75F6A5188C5FA4234E950373D7F9568B4171AE4392E383D4058F5E454712E1284A93B1371C83D2ACCB42820AD4612484C6D24DE8556A6D640B83BDF707634B7B96D94763D6C1E4FC88A29B3C5A87C41F731D2E457B816C94AD73094C12AEE4C011DE28F214D47824FB8661424C40B4F36A2B058E579A94AD6AD22274A768DA7B5001F951D67881FEF4CB079E010942024EDC7B5CD2CAD2162F7BB34989CAD97C1101262CA4D8DB83D4567DEC954D7C5EA00FC40C0EC0EF134E9AC404B90AB294094C7CA8B5E102C42E4255B8EFD66B9165707523B67D3A9C6E3C83E518D6F0ED86DD041F88441B2803BC6FBD7B5731E19D427CC26FBE99FAF7AEA7F5E073FE3CCAFC59992C81E5ACA4A4CDA38DA92BD877712969B049715EA3D813F12B8150CC70CB75D2028046ADF7B0DEB45E1DF1232D7EE4B2B0B4DB5C6A51E8A3D0445AA8952B1E5BBA6098DCAD867FF2C4979F546A26C96C6F6EA6DCD56F2302D4B7E538A767490A51005E06C6E3BD0F8B696B794BD45292A99165103ED49F33CC1D714D951D442442B4C157104FCA8C15B279292E07B93E4E0A95E6AFCB09540488548F7344E7CDB0549285A4239493B46D59DC0E21C6CEADE22CA937911238157B38875E5296A034992404802DB08E959A62A5096D5B8DD39A36B21009B0325291F0A44C7134D70A86DB1ADB735249954D8A0A922750DF4D871591C3B052B8B81D09B1078EE29F61723789716CB40EA09484054448126E6E0C0B76A47249F267D3CA6B61BA17A84D7BC2542C45C476A578065C6896DCF4AF88DBE628F6C9B92798B580AEA8CB5109C34C8619867619652AB15A8921026126C0937EC2B1ADBEB75456B54926F3DE4F14DB3B6E5B9E948F02B807BD33143DA544F27AD41D5F22DED6AF14AE82D54B8E4D218E4AFEF5126A3C5784D632382AA3E64D416493A53127AD1652011116A494B495863D481C344F0401F9FB551E651B8ECC348B0956DB6D490AD441DEDBDA7FDA841B7C8D96093D28216E8EB423CE8A6580CB35C29D94A781693DCF4147A32F616DA92CE952BDF91D69F5AE09E862ECBF36B04E9488E837A21CC232F28150854F1CF6341B793BC924A9B993F84823E546B7969D274FA55C4D49D7299D4ADADC2339C202D94C010418EC38ED59FCE1416E21490121484C08E96B5307312F04A90B4851D8C1BFBC74A0B3770436900052660F1D40A30BBDC1929C2D1EE585A6D60BB3DC8B7D7AD1EA6DA12507CC6D504A458DA62DC8159FD3792227B6D36A69896CB450124C8064C7CE9A51564E12DB8D839BCADAC4254A691E5E88FE2BF683B9A03179406E55731C76EA2AE4E66FA362083788EB5562314B7A2D113B4DF6E29529A75E0DEA63A19E31FF002F10C9F88048240EE3B53A46235585E6E0F6358F658D7222143ACC5E88692A6C4A54653BFCC4C54F261527F6571758A1B347D3B2BCFD78647969282266E013781FA5757CD3CE5B9EA56FB723BFEB5D49E8BF92FF009389FF0011A655ADCB944274CA973F098B6F3AA676B54CE64968E969282904051204A8F2677F6AAF1B8271587529B73D21452B427EA156BD8589A51976013E7A13ABCD6D24151D926D363D01AAD2673C3249AAE4D8B99BB1A421B952964048295589223518B1133EC2B35E27C9CB2FA82141CD649D49330A373206D7AD1FFC550D1B381238933F4F973423D9CE15440090E286C133B8FBD2C255C2619C753DD8932DC294C2DD04490944830491329B6FEF5A6C365A22E45C7AA44111B003813D687C42DEC496CAD21B083A900FE1B5BD20C535C060C19056B55A4DC01F402B4E56838E35B99BC6E21054A461552B4124882018B5AD0685CA7C4D8A0A3A0C286F3B037064F69DA8953294E2DBF29005D53A6DB4FC439DE8E6B2905CD414403129005CCCDE966E09534561193769D0363F2CC429097C028112A0126491CCF13BDE986578E0E03D7E150EFB83F3DAB4397E294B6DC6927D46C6781D639F6AC5E37FF2CF96B7F54481B6A3B11B11F6A9F4D9F549C19BADC1DAA687B8C68441DA2B1E094A8C706D5ABC0E235A4F4ACF6638729709EB7AF47C1E61E1777AF50926A6C312075ABCA6D4A1481142AB5D4DC5D0AEBDF2AC62F69B8216A509D80A2B0E8D7E9D5B1B83C8ED495C33CEDD4D45A0A528F972045C8E953946FC9D38E54B8366B630ED2540247AB73BFE66B369730AC88D6E2D7BC2026FD249354129830B5EDCDFEF4331871303F49EF2291452E5946E4F82DCC312E6263CB41481B89DFDF8AF32AC95495A54B3A44DF49209A2192A41941F7E9F4A6D8DC42109055A803CA448E2FDA8B9B5B232C29EEC729401004DBBD1094823837FCA93E182CA650B0B49D8EC7E74A1AC6BECBFA966D37483223A7BD4141B2929A468B1780045ED06C791EC79AC363D0A5ACA604A5444CDF78BD6BB39CE41003447AAE39FAD236F0BAC9BFAAE49FE754C571F70B956A8EC2F534A4A82543E1820EF6DE6A4B7D4F1017063681133D68C4BAB6C824EA817B7145E5B812E2CFEF2391290481D26AB29A4AD9CB0C7393D091664791A5D04A95A4247A4F04D16EF85D248D2ED87DFB56832DC121284A62605C91BD3567040CC40E95E565EAE6A5699E947A48423DC6071196A9B4C9048248D46FB8247DA3E7403482AFDDAA44DC2BF0F483799ADCF8894D8D2852652412A09B18FC241E0D6343A4A8E9234CFA411C0FD6BAFA7CB29C6D9E77518A307B1EA99427D24DC75584FE4ABD7549E74A8C859038109FD44D7957B673DA18E032D516CB85C29047AA07C066F61BFB9A1F37F0E3A1B0B414BA83CA15733792040FE542E19F5A4C05694C9372485055EF7BC0EB5E617327984942420A49D4647C43A0E8228534ED1D11C8AA988DD62277B083FCA6AE61640012902F120CF79A2F34C6EB21611A7503E8E2662856536B020C46F68EBFA5553B5B926E51766CF0D884E9127899ED5E607C4680974B6952E019501012389F7ACF60709E6234296A0091A801781C0FE756A70E1A42DA4CFC527BF03DEA2E31477C1C9D2F00397E2CA1D2F2A48362074276A7D9C63D6D042D30A6D769E84F06A96B0ED95A123D29290547BF36EA6AF69F4B64E1DF12DB9F0AB804FDB8AD28A7CA0C1E9B40D97F8AD6DAA509009E4DE076A8E39D2B95DCABAFB9B7E74B3F63295292B4C14DBFBEB4E30505300824477D8CDFE743D38C5DC792D16E51A915E4F8D524C2B6B89E010481F90A6999320C1DE07DFF4ACF8594B8E0DED31EE69D36FA4B479299AE94F63CA9C69B2849E9143629E3D8553897C0EB278ED40A8A964C4240DCA8C0FEB5909645EC56FBFCAA183C3ADC329831C48B7BD30C99969C0AF317EB9B69B7A7A9B41A60BF0CA41D495281EB00FD683916842F7622719804AB4A7EE7DA854BA4FA802522B5C720660A964AA2F2A263E9C567F00A30ED868B94EC3B08ED4B65ADD8CB2DC903CD25C5952750300458026FB533C0E5684589D5A8C4C45BF9522C83340C2495EA5136005C0F716FBD30733E6CAF5252606F68DFB4D72658E67B22D0717C8E3FF000E832564241B009DE3F4ACE63F52494103CB1200FF002C8EB4F1FCDC14A4A5D847E2B4287CA80CECCA9BD1046924999906C3EC7EB5BA7535BC8867924AA2C4B85C42D0D96D32350B286C20DE6AB6D95944124C99B5E7FAD3167D27891788EB44E0D0544931A79EDFDF6AEBD443536A98BBF635850541D317E6E38B6D5E34FA9B51D560AEC67E5DA99A8841F4991C81F7039A86254A2124098123FD24EC3A1B8A176F70ACBA5503BCCA57173A4D8CC01F5A2328F31951586B50513B1E38833D2AAC4E242510946A0ADCAF827F0C0A1B1AE3A348528A67648E295C752A2D1C9A5EA34F88F1396C021856F72B848F96F5A4CBF11E633AF6D42DFDC57CC834AD3EA3278951333FCA7F2A7F87F1038DB486823514EE41B46FF3AE3CBD1C76D2571F54DBEE00F16E289752DC95247C44F5E05BA509815208124055A7509063B6FB5518A25C756B22DBA88EBC548322EA20408B758EFC576C229468E5C9272958C1C489216124F1C5B8B4DABDA1CA0ABD41420D756D289E9455871E8F92BFEAA8E23FE6A7FF00AFEC2BABAB1BC31965AD2483291F41D2A8CE120698116AEAEA08BCFF00C453959F57D28E3FFF004ABD8575752B3B71FB57F42E74FEF07CFEE68CCE120E1248B823EF5D5D45F820B890B759241249B0DFDA9878707EED67FCEAFB9AEAEA67C158F20EBF8947FCC9A219361F2FB2ABABA9E27164F22C77757B8FBD0C6E113D7FED15E575122871824006C06E9AD5B5F0FCABABAA6CEC8FB503E2FF00E52FFD07ED58AC26DFFC47D8575756415EE44B13B0F7A835B1FF0049FB57B5D4E847C93C67C387F657FD74C30FF10FF42ABCAEA591CB3E43D81F63FAD442CC26E6BABA943222E89DFAA3F5A960D4759BF4FF00A135ED75115722ACB964AC02491FD4D1588F8D3ED5D5D4CB928BDC5B96DD689E955E0CFADEFF005FFDC8AEAEA285990C588D71FDDE8673F4FD0D75752A19F08A183E915E57575101FFD9";
byte[] decByte3 = System.Convert.FromBase64String(myBytes);
Bitmap myIcon = Bytes2Bimap(decByte3);
Drawable myIconD = new BitmapDrawable(myIcon);
imageView.Background = myIconD;
};
}
public Bitmap Bytes2Bimap(byte[] b)
{
if (b.Length != 0)
{
return BitmapFactory.DecodeByteArray(b, 0, b.Length);
}
else
{
return null;
}
}
How to capture shadow or elevation of views in the layout of the activity in a screenshots.This code take a screenshot for the view but it's not showing the shadow of the viewsenter image description here
View screenView = parentMain;
screenView.buildDrawingCache();
screenView.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(screenView.getWidth() , screenView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
screenView.layout(0, 0, screenView.getLayoutParams().width, screenView.getLayoutParams().height);
screenView.draw(c);
screenView.setDrawingCacheEnabled(false);
fakeImgView.setImageBitmap(bitmap);
Even if we add the harware acceleration at activity level it does not provides any effect.
Appreciate any alternative approaches
the result
Try this.
CardView card = (CardView) findViewById(R.id.card);
Now just pass the card to captureScreenShot(). It returns the bitmap and save that bitmap saveImage().
You can pass any view Like RelativeLayout, LinearLayout etc any view can pass to captureScreenShot().
// Function which capture Screenshot
public Bitmap captureScreenShot(View view) {
/*
* Creating a Bitmap of view with ARGB_4444.
* */
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_4444);
Canvas canvas = new Canvas(bitmap);
Drawable backgroundDrawable = view.getBackground();
if (backgroundDrawable != null) {
backgroundDrawable.draw(canvas);
} else {
canvas.drawColor(Color.parseColor("#80000000"));
}
view.draw(canvas);
return bitmap;
}
// Function which Save image.
private void saveImage(Bitmap bitmap) {
File file = // Your Storage directory name + your filename
if (file == null) {
return;
}
try {
FileOutputStream fos = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Finally call this function like this.
saveImage(captureScreenShot(card));
Now set Your Image like this.
File file = new File(“yourImageFilePath”);
if(file.exists())
{
yourImageView.setImageURI(Uri.fromFile(file));
}
Note : If setImageURI() not working then you can use below code.
File file = new File(“yourImageFilePath”);
if(file.exists())
{
Bitmap bitmap = BitmapFactory.decodeFile(file.toString());
yourImageView.setImageBitmap(bitmap);
}
I was having some problem when trying to attach a generated QR code as attachment using email in Android Programming. Here is the part where I generate the QR code and then call the send email:
#SuppressLint("NewApi")
private void generateQR() {
// Find screen size
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Point point = new Point();
display.getSize(point);
int width = point.x;
int height = point.y;
// Encode with a QR Code image
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrInputText, null,
Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(),
smallerDimension);
try {
Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
ImageView myImage = (ImageView) findViewById(R.id.ivImage);
myImage.setImageBitmap(bitmap);
new SendEmailAsyncTask().execute(bitmap);
} catch (WriterException e) {
e.printStackTrace();
}
}
class SendEmailAsyncTask extends AsyncTask <Bitmap, Void, Boolean> {
#Override
protected Boolean doInBackground(Bitmap... params) {
GMailSender sender = new GMailSender("something#gmail.com","pwd");
try {
sender.sendMail("Successful Event Registration QR Code",params[0], "something#gmail.com", "something#gmail.com");
System.out.println("send");
} catch (Exception e) {
System.err.println("err"+e);
Log.e("SendMail", e.getMessage(), e);
}
return null;
}
}
However, I am getting error message at the sendMail that line:
The method sendMail(String, String, String, String) in the type GMailSender is not applicable for the arguments (String, Bitmap, String, String)
Because previously when I replace the params[0], it was a string before that. But then I have to pass in the generated QR code bitmap into the email content. Any ideas?
Thanks in advance.
Update
Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
ImageView myImage = (ImageView) findViewById(R.id.ivImage);
myImage.setImageBitmap(bitmap);
counterQR++;
String path = Environment.getExternalStorageDirectory().toString();
OutputStream fOut = null;
File file = new File(path, "eNeighbourhood"+counterQR+".jpg");
fOut = new FileOutputStream(file);
Bitmap pictureBitmap = getImageBitmap(bitmap); // obtaining the Bitmap
pictureBitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut);
fOut.flush();
fOut.close();
MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
With these code above, I am trying to convert bitmap into file so that I can modify the sendMail() by taking in file parameter as well. However, I am getting getImageBitmap is undefined for MainActivity