android-bitmap

When saving bitmap to disk, solid paths show artifacts

穿精又带淫゛_ 提交于 2019-12-21 05:02:41
问题 [Edit: I've made a minimal project to try to narrow down what's going on. The code at the bottom still generates the same artifacts when saved] I have an app that draws simple 2D geometry using Paths. The shapes are all solid colors, sometimes with alpha < 255, and may be decorated with lines. In the View that draws the geometry, there has never been an issue with how things get drawn. However, when I use the same code to draw to a Bitmap, and then save it as either a JPEG (with 100 quality)

Getting Bitmap from TextLayout in onCreate

て烟熏妆下的殇ゞ 提交于 2019-12-20 07:04:49
问题 I am able to convert a Layout with a TextView into a Bitmap , as long as the event that happens after onCreate() . But when I try during on create, it does not work. Is there a way to get this to work? I have tried using inflate() in various ways with no joy. There are various answered questions including this one that address the technique that I'm successfully using in my code. But the success does not include employing the technique from onCreate() . public class MainActivity extends

Get images from PHP-MySql server to Android using json

China☆狼群 提交于 2019-12-20 05:02:58
问题 i am devloping an application which download image from php-server and display image in image view ..but when i receive image from php page if (!empty($result)) { if (mysql_num_rows($result) > 0) { $result = mysql_fetch_array($result); $user = array(); $user["image"] = base64_encode($result["image"]); $response["success"] = 1; $response["image_table"] = array(); array_push($response["image_table"], $user); echo json_encode($response); } else { $response["success"] = 0; $response["message"] =

Compress bitmap to a specific byte size in Android

南笙酒味 提交于 2019-12-19 10:14:41
问题 Is there a way to compress Bitmap to a specific byte size? For example, 1.5MB. The matter is all the examples I have seen so far were resizing width and height, but my requirement is to resize the bytes. Is that possible? Also, what is the most straightforward and right way to compress the Bitmap? I am quite novice to this topic and would like to go right direction from the beginning. 回答1: You can calculate the size of a bitmap quite easily by width * height * bytes per pixel = size Where

How to save Exif data after bitmap compression in Android

孤街醉人 提交于 2019-12-19 07:16:09
问题 After taking a picture with the camera intent, I compress the bitmap to lower the file size. The problem is that after compression, it loses all EXIF data. I have no problem retrieving the original EXIF data, however, how do I add this EXIFF data after compression into the byte array ? (My guess is to take the byte array and create a bitmap of that, then add the old EXIF data and thereafter add to byte array again, but this is a mobile application and I'm taking a lot of images so I don't

How to use RoundedBitmapDrawable

点点圈 提交于 2019-12-18 10:10:13
问题 Has anyone managed to use RoundedBitmapDrawable ? Correct me if I'm wrong, but to my understanding, it makes a circular image from a regular rectangular image. What I've tried so far is this RoundedBitmapDrawable.createRoundedBitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), iconResource)) What I tried to achieve: transform any image to a circular image and show it using an ImageView. In case I mixed things up and all that I said is non-sense. Is it possible (or

Android WebView offscreen/bitmap rendering issue

﹥>﹥吖頭↗ 提交于 2019-12-18 09:14:02
问题 I'd like to render an HTML fragment to a WebView and then grab a bitmap of it. Here is a code fragment (which is inside of MainActivity.onCreate): final WebView view = new WebView(this); String summary = "<html><body>You scored <b>192</b> points.</body></html>"; view.loadData(summary, "text/html", null); Bitmap bitmap= Bitmap.createBitmap(400, 400, Bitmap.Config.ARGB_8888); Canvas offscreen = new Canvas(bitmap); view.draw(offscreen); When 'bitmap' is originally created, it is transparent.

How to save bitmap to Firebase

只谈情不闲聊 提交于 2019-12-18 07:12:06
问题 I created a simple application which crop the image . Now I want to save this image to the Fire base . photo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Intent imageDownload = new Intent(Intent.ACTION_PICK,MediaStore.Images.Media.EXTERNAL_CONTENT_URI); Intent imageDownload=new Intent(); imageDownload.setAction(Intent.ACTION_GET_CONTENT); imageDownload.setType("image/*"); imageDownload.putExtra("crop", "true"); imageDownload.putExtra("aspectX", 1);

How to send an image from Android client to Node.js server via HttpUrlConnection?

流过昼夜 提交于 2019-12-18 03:46:42
问题 I am trying to send an image to the server using HttpUrlConnection, because it's recommended by Google. I decided to convert the image into Base64 string and send it to the server where I decoded it into .jpg file. But this method is only feasible with small-sized thumbnails and I cannot send a full-sized images. Here is the android client code: public static void postData(Bitmap imageToSend) { try { URL url = new URL("http://"); HttpURLConnection conn = (HttpURLConnection) url.openConnection

Android Bitmap Masking (Xfermode) leaves opaque black background behind

*爱你&永不变心* 提交于 2019-12-18 02:44:06
问题 I have a custom view and in the onDraw() , I am trying to perform bitmap masking. I have a squareBitmap (red color) which fills the whole view, and I have a circleBitmap (blue color) that acts as the mask. I am using the mode: PorterDuff.Mode.DST_IN . The result I am expecting is a RED filled circle. I get that, but I also get a BLACK opaque background. I don't want this opaque background, rather it should be transparent. Figure 1 is the result I got, and Figure 2 is the result that I am