您的位置:首页 > 移动开发 > Android开发

Best code examples for Bitmap compress method (android.graphics.Bitmap.compress)

2015-11-06 10:39 651 查看

from: http://www.codota.com/android/methods/android.graphics.Bitmap/compress

Best code examples for Bitmap compress method (android.graphics.Bitmap.compress)

These code examples were ranked by Codota’s semantic indexing as the best open source examples forBitmap compress method.

You can now enable Codota on your own code to easily search and navigate your Java codebase.
Bitmap compress examples from Open Source projects



Code
example from Github project android/platform_frameworks_base, TextureViewActivity.java »


This code example shows how to use the following methods: compress

62:	b.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


7
CodeRank



Code
example from Github project octo-online/robospice, InFileBitmapObjectPersister.java »


This code example shows how to use the following methods: compress

56:	boolean didCompress = data.compress(compressFormat, quality, out);
Full Snippet Info


6
CodeRank



Code
example from Github project socialize/socialize-sdk-android, ImageUtils.java »


This code example shows how to use the following methods: compress, createBitmap, getHeight, getWidth

46:	int width = bitmap.getWidth();
-
52:	int height = (int)((float)bitmap.getHeight() * ratio);
53:	bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height);
-
57:	bitmap.compress(format, 100, stream);
Full Snippet Info


7
CodeRank



Code
example from Github project appcelerator/titanium_modules, ImageFactoryModule.java »


This code example shows how to use the following methods: compress, recycle

251:	if (image.compress(CompressFormat.JPEG, (int)(compressionQuality * 100), bos)) {
-
265:	image.recycle();
Full Snippet Info


7
CodeRank



Code
example from Github project android/platform_frameworks_base, GLTextureViewActivity.java »


This code example shows how to use the following methods: compress

72:	b.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


6
CodeRank



Code
example from Github project CyanogenMod/android_packages_apps_Contacts, PhotoEditorView.java »


This code example shows how to use the following methods: compress, getHeight, getWidth

125:	final int size = photo.getWidth() * photo.getHeight() * 4;
-
129:	photo.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


7
CodeRank



Code
example from Github project PomepuyN/BlurEffectForAndroidDesign, ImageUtils.java »


This code example shows how to use the following methods: compress

34:	image.compress(Bitmap.CompressFormat.PNG, 90, fos);
Full Snippet Info


6
CodeRank



Code
example from Github project yanchenko/droidparts, BitmapConverter.java »


This code example shows how to use the following methods: compress

57:	val.compress(CompressFormat.PNG, 0, baos);
Full Snippet Info


6
CodeRank



Code
example from Github project android/platform_packages_providers_contactsprovider, PhotoProcessor.java »


This code example shows how to use the following methods: compress, getHeight, getWidth

249:	final boolean compressed = b.compress(Bitmap.CompressFormat.JPEG, quality, baos);
-
288:	(mDisplayPhoto.getWidth() > mThumbnailPhoto.getWidth() ||
289:	mDisplayPhoto.getHeight() > mThumbnailPhoto.getHeight());
Full Snippet Info


6
CodeRank



Code
example from Github project robisaks/LoL-Chat, BeemAvatarManager.java »


This code example shows how to use the following methods: compress, getHeight, getWidth

146:	info.setHeight(bmp.getHeight());
147:	info.setWidth(bmp.getWidth());
-
164:	if (bitmap.compress(format, quality, bos))
Full Snippet Info


6
CodeRank



Code
example from Github project OESF/Embedded-Master-ARM, PhotoAppWidgetProvider.java »


This code example shows how to use the following methods: compress, getHeight, getWidth

128:	int size = bitmap.getWidth() * bitmap.getHeight() * 4;
-
130:	bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


7
CodeRank



Code
example from Github project loopj/android-smart-image-view, WebImageCache.java »


This code example shows how to use the following methods: compress

110:	bitmap.compress(CompressFormat.PNG, 100, ostream);
Full Snippet Info


6
CodeRank



Code
example from Github project ushahidi/Ushahidi_Android, PhotoUtils.java »


This code example shows how to use the following methods: compress, recycle

188:	bitmap.compress(Bitmap.CompressFormat.JPEG, 75, byteArray);
189:	bitmap.recycle();
Full Snippet Info


6
CodeRank



Code
example from Github project android/platform_packages_apps_contacts, ContactPhotoUtils.java »


This code example shows how to use the following methods: compress, getHeight, getWidth

107:	final int size = bitmap.getWidth() * bitmap.getHeight() * 4;
-
110:	bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


7
CodeRank



Code
example from Github project yixia/ZI, BitmapHelper.java »


This code example shows how to use the following methods: compress, isRecycled, recycle

55:	if (bitmap != null && !bitmap.isRecycled()) {
-
59:	bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
-
67:	bitmap.recycle();
Full Snippet Info


7
CodeRank



Code
example from Github project gallir/SpokenPic, ImageUtils.java »


This code example shows how to use the following methods: compress, createBitmap, getHeight, getWidth

174:	bitmap.compress(CompressFormat.JPEG, 85, new FileOutputStream(thumbNail));
-
188:	return Bitmap.createBitmap(image, 0, 0,
189:	image.getWidth(), image.getHeight(),
Full Snippet Info


7
CodeRank



Code
example from Github project AOKP/frameworks_base_disabled, GetBitmapActivity.java »


This code example shows how to use the following methods: compress

59:	b.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


6
CodeRank



Code
example from Github project oschina/android-app, ImageUtils.java »


This code example shows how to use the following methods: compress

71:	bitmap.compress(CompressFormat.JPEG, quality, stream);
Full Snippet Info


6
CodeRank



Code
example from Github project vogella/vogella, ViewScreenshotActivity.java »


This code example shows how to use the following methods: compress

42:	bitmap.compress(Bitmap.CompressFormat.PNG, 90, fOut);
Full Snippet Info


6
CodeRank



Code
example from Github project boombuler/ADWLauncher2, ItemInfo.java »


This code example shows how to use the following methods: compress, getHeight, getWidth

143:	int size = bitmap.getWidth() * bitmap.getHeight() * 4;
-
146:	bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


7
CodeRank



Code
example from Github project Odaym/Cura, ScreenCapture.java »


This code example shows how to use the following methods: compress, insertImage

56:	b.compress(Bitmap.CompressFormat.PNG, 80, fos);
-
59:	MediaStore.Images.Media.insertImage(cr, b, "Screen", "screen");
Full Snippet Info


6
CodeRank



Code
example from Github project AOKP/frameworks_base_disabled, TextureViewActivity.java »


This code example shows how to use the following methods: compress

62:	b.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


6
CodeRank



Code
example from Github project duberton/AppShare, ImageUtils.java »


This code example shows how to use the following methods: compress, close, toByteArray

14:	ByteArrayOutputStream stream = new ByteArrayOutputStream();
15:	bm.getBitmap().compress(Bitmap.CompressFormat.JPEG, 100, stream);
16:	byte[] byteArray = stream.toByteArray();
17:	stream.close();
Full Snippet Info


6
CodeRank



Code
example from Github project todoroo/astrid, RequestTests.java »


This code example shows how to use the following methods: compress

453:	image.compress(Bitmap.CompressFormat.PNG, 100, outStream);
Full Snippet Info


6
CodeRank



Code
example from Github project TideSDK/TideSDK-Mobile, TiBlob.java »


This code example shows how to use the following methods: compress, getHeight, getWidth, hasAlpha

139:	if (image.hasAlpha()) {
140:	if (image.compress(CompressFormat.PNG, 100, bos)) {
-
145:	if (image.compress(CompressFormat.JPEG, 100, bos)) {
-
152:	blob.width = image.getWidth();
153:	blob.height = image.getHeight();
Full Snippet Info


6
CodeRank



Code
example from Github project OESF/OHA-Android-2.2_r1.1, PhotoAppWidgetProvider.java »


This code example shows how to use the following methods: compress, getHeight, getWidth

121:	int size = bitmap.getWidth() * bitmap.getHeight() * 4;
-
123:	bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


6
CodeRank



Code
example from Github project dtitov/pickncrop, MainActivity.java »


This code example shows how to use the following methods: compress, close

196:	FileOutputStream fileOutputStream = new FileOutputStream(imageFile);
-
198:	outputSize, false).compress(CompressFormat.JPEG, 100,
-
200:	fileOutputStream.close();
Full Snippet Info


6
CodeRank



Code
example from Github project OESF/OHA-Android-2.3.4_r1.0, ItemInfo.java »


This code example shows how to use the following methods: compress, getHeight, getWidth

118:	int size = bitmap.getWidth() * bitmap.getHeight() * 4;
-
121:	bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


6
CodeRank



Code
example from Github project OESF/Embedded-Master-ARM, WidgetPreviewActivity.java »


This code example shows how to use the following methods: compress

261:	if (!bmp.compress(CompressFormat.PNG, 100, fout)) {
Full Snippet Info


6
CodeRank



Code
example from Github project mitchellhislop/apps-for-android, UserDatabase.java »


This code example shows how to use the following methods: compress, getHeight, getWidth

88:	int size = bitmap.getWidth() * bitmap.getHeight() * 2;
-
91:	bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


6
CodeRank



Code
example from Github project cattong/YiBo, ImageUtil.java »


This code example shows how to use the following methods: compress, recycle

424:	rotated.compress(getCompressFormat(dest), 100, fileOutputStream);
-
443:	rotated.recycle();
Full Snippet Info


6
CodeRank



Code
example from Github project RayCai/RemoteLauncher, ApplicationInfo.java »


This code example shows how to use the following methods: compress, toByteArray

31:	ByteArrayOutputStream baops = new ByteArrayOutputStream();
32:	bitmap.getBitmap().compress(CompressFormat.PNG, 100, baops);
-
34:	return baops.toByteArray();
Full Snippet Info


5
CodeRank



Code
example from Github project ChameleonOS/android_packages_apps_ChaOSLauncher, ItemInfo.java »


This code example shows how to use the following methods: compress, getHeight, getWidth

182:	int size = bitmap.getWidth() * bitmap.getHeight() * 4;
-
185:	bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
Full Snippet Info


6
CodeRank



Code
example from Github project mitukiii/TumblifeForAndroid, TLExplorer.java »


This code example shows how to use the following methods: toString

41:	public static final String         IMAGE_PNG_EXTENSION = IMAGE_PNG_FORMAT.toString().toLowerCase();
Full Snippet Info


5
CodeRank



Code
example from Github project stanfy/enroscar, BitmapPart.java »


This code example shows how to use the following methods: name

43:	setContentType("image/" + compressFormat.name().toLowerCase(Locale.US));
Full Snippet Info


5
CodeRank



Code
example from Github project AndrewChanChina/ppc1, ImageThreadLoader.java »


This code example shows how to use the following methods: name

53:	+ compressedImageFormat.name();
Full Snippet Info


4
CodeRank



Code
example from Github project CMPUT301F12T01/classproject, TakePhotoActivity.java »


This code example shows how to use the following methods: toString

42:	photoType = CompressFormat.JPEG.toString().toLowerCase();
Full Snippet Info


4
CodeRank



Code
example from Github project AndrewChanChina/ppc1, ImageThreadLoader.java »


This code example shows how to use the following methods: name

53:	+ compressedImageFormat.name();
Full Snippet Info


4
CodeRank



Code
example from Github project mrschtief/PartyBolle, ImageCache.java »


This code example shows how to use the following methods: name

196:	+ compressedImageFormat.name();
Full Snippet Info


4
CodeRank



Code
example from Github project sinnerschrader-mobile/droid-fu, ImageCache.java »


This code example shows how to use the following methods: name

91:	return Integer.toHexString(imageUrl.hashCode()) + "." + compressedImageFormat.name();
Full Snippet Info


4
CodeRank



Code
example from Github project tomleese/Platinum, GalleryActivity.java »


This code example shows how to use the following methods: name

51:	intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.name());
Full Snippet Info


4
CodeRank

More examples using Android Bitmap class (android.graphics.Bitmap) »
Related Bitmap compress Questions & Answers:



Upload
compressed image


31:	    String byteImage = null;
32:	    ByteArrayOutputStream baos = new ByteArrayOutputStream();
33:	    image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
34:	    byte[] b = baos.toByteArray();
35:	    try
-
45:	    {
46:	        baos = new ByteArrayOutputStream();
47:	        image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
48:	        b = baos.toByteArray();
49:	        byteImage = Base64.encodeToString(b, Base64.DEFAULT);





Noman Hamid's full answer:

You need to do this man:

1: Get Image and check size. For example: if fileSize<=1MB

2: ShrinkBitmap (So that large image won't cause memory issues. See ShrinkBitmap() below.

3: If you want to Encode to base64 or else then you can do it and compress to 100%. See Encodetobase64() below

4: Send to Server

public Bitmap ShrinkBitmap(String file, int width, int height)
{
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions);

int heightRatio = (int) Math.ceil(bmpFactoryOptions.outHeight / (float) height);
int widthRatio = (int) Math.ceil(bmpFactoryOptions.outWidth / (float) width);

if(heightRatio > 1 || widthRatio > 1)
{
if(heightRatio > widthRatio)
{
bmpFactoryOptions.inSampleSize = heightRatio;
}
else
{
bmpFactoryOptions.inSampleSize = widthRatio;
}
}

bmpFactoryOptions.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions);
return bitmap;
}

public String encodeTobase64(Bitmap image)
{
String byteImage = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] b = baos.toByteArray();
try
{
System.gc();
byteImage = Base64.encodeToString(b, Base64.DEFAULT);
}
catch (Exception e)
{
e.printStackTrace();
}
catch (OutOfMemoryError e)
{
baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
b = baos.toByteArray();
byteImage = Base64.encodeToString(b, Base64.DEFAULT);
Log.e("Bitmap", "Out of memory error catched");
}
return byteImage;
}

This encoding function is compressing bitmap also.

Goodluck!!

Read More



Upload
multiple images to server from Android app


7:	  Bitmap bitmap = decodeFile(file);
8:	  ByteArrayOutputStream bos = new ByteArrayOutputStream();
9:	  bitmap.compress(CompressFormat.JPEG, 75, bos);
10:	  byte[] data = bos.toByteArray();
11:





nKn's full answer:

You can simply put it in a loop. Assuming you have an
array
of files (in this example called
myFiles
), you would just do something like this. Bear in mind that it's important of each iteration to create a new object of everything,
so this way you're making sure you're sending always a different and independent object.

int i = 0;

String[] myFiles = { "C:\path1.jpg", "C:\path2.jpg" };

for (String selectedPath : myFiles) {
File file = new File(selectedPath);
Bitmap bitmap = decodeFile(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG, 75, bos);
byte[] data = bos.toByteArray();

try {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(urlString);

ByteArrayBody bab = new ByteArrayBody(data, "test.jpg");

MultipartEntity reqEntity = new MultipartEntity();

reqEntity.addPart("path[" + String.valueOf(i++) + "]", bab);

post.setEntity(reqEntity);
HttpResponse response = client.execute(post);
resEntity = response.getEntity();
response_str = EntityUtils.toString(resEntity);
}
catch (...) { ... }
}

Read More



Video
Uploading Android


26:	            Bitmap out = Constant.bitmapResize(TrackFragment.btmTrackImg,308, 296) ;//Bitmap.createScaledBitmap(TrackFragment.btmTrackImg, 408, 396,true);
27:	            ByteArrayOutputStream bos = new ByteArrayOutputStream();
28:	            out.compress(CompressFormat.JPEG, 50, bos);
29:	            byte[] data = bos.toByteArray();
30:





M.J.'s full answer:

I have done this before , i have track which can be up to 80mb and uploading using
MultiPartEntity
try below function.

public class asyncUploadtrack extends AsyncTask<Void, Integer, Void>
{
HttpResponse response;
private android.app.ProgressDialog dialog;
long totalSize;

protected void onPostExecute(String result)
{

}
@Override
protected void onPreExecute()
{

}
@Override
protected void onProgressUpdate(Integer... values)
{

}
protected Void doInBackground(Void... params)
{
Log.i("Do in Backgtound", "Background");
String url =app.WEB_API_URL+"?op="+ Constant.METHOD_UPLOAD_TRACK;
File video = new File(trackPath); // path of file
Bitmap out = Constant.bitmapResize(TrackFragment.btmTrackImg,308, 296) ;//Bitmap.createScaledBitmap(TrackFragment.btmTrackImg, 408, 396,true);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
out.compress(CompressFormat.JPEG, 50, bos);
byte[] data = bos.toByteArray();

HttpClient httpclient = new DefaultHttpClient();
HttpPost post = new HttpPost(url);

try
{
MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
multipartEntity.addPart("music", new FileBody(video));
multipartEntity.addPart("title",new StringBody(trackTitle));
multipartEntity.addPart("user", new StringBody(app.preferences.getStringPref("userId")));

multipartEntity.addPart("filename", new StringBody("song.mp3"));
multipartEntity.addPart("avatar",new ByteArrayBody(data, "trackImage"));
//After adding everything we get the content's lenght
totalSize = multipartEntity.getContentLength();
post.setEntity(multipartEntity);
response = httpclient.execute(post);
try
{
Log.i("Response is",response.getStatusLine().toString());
}
catch (Exception e)
{
e.printStackTrace();
}
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
}

Read More



How
to take screenshot of webview in Android


13:	                            if ( fos != null )
14:	                            {
15:	                                b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
16:
17:	                                fos.close();





Spring Breaker's full answer:

Do as follows

private void TakeScreenshot()
{
Picture picture = webview.capturePicture();
Bitmap  b = Bitmap.createBitmap( picture.getWidth(),
picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas( b );

picture.draw( c );
FileOutputStream fos = null;
try {

fos = new FileOutputStream( "mnt/sdcard/yahoo.jpg" );
if ( fos != null )
{
b.compress(Bitmap.CompressFormat.JPEG, 100, fos);

fos.close();
}
}
catch( Exception e )
{

}
}

N.B: Take the screenshot after the
WebView
finishes loading otherwise you will get a blank screen.

Read More



How
to set wallpaper permanently in android


52:	public String BitMapToString(Bitmap bitmap){
53:	    ByteArrayOutputStream baos=new  ByteArrayOutputStream();
54:	    bitmap.compress(Bitmap.CompressFormat.PNG,100, baos);
55:	    byte [] b=baos.toByteArray();
56:	    String temp=Base64.encodeToString(b, Base64.DEFAULT);





gvsharma's full answer:

yesterday i have done this task..getting image from either gallery or through camera and set that as wall paper.for this i did like this.First get the image from gallery or camera.second compress or rescale it properly according to your need.third save that
image in sharedpreferences so that if image is deleted from gallery or phone memory even in that case also it will be as it is a wall paper.finally set the image as wall paper in onCreate Method of activity .

public class Util {

public static final String PREFERENCES_NAME = "prefs";
public static SharedPreferences getSharedPreference(Context context) {
return context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
}
public static String getBackgroundImagePath(Context context) {
return getSharedPreference(context).getString("imagepath","");
}

public static void setBackgroundImagePath(Context context, String path) {
Editor edit = getSharedPreference(context).edit();
edit.putString("imagepath", path);
edit.commit();
}

}

call this setBackgroundImagePath method from activity by passing string path and context.like this//your image path

String path = "";
Util.setBackgroundImagePath(getApplicationContext(), path);

from onCreate() of activity,

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.full_image);
face = Typeface.createFromAsset(getAssets(), "fonts/ABEAKRG.TTF");
Intent i = getIntent();
position = i.getExtras().getInt("id");
full = (LinearLayout) findViewById(R.id.full);
btn = (Button)findViewById(R.id.btn);
btn.setTypeface(face);
Bitmap path = StringToBitMap(Util.getBackgroundImagePath(getApplicationContext()));
if (path != null) {
full.setBackgroundDrawable(new BitmapDrawable((path)));
}else {
full.setBackgroundDrawable(R.drawable.defaultImage);
}
btn.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
Bitmap tempbitMap = BitmapFactory.decodeResource(getResources(), mThumbId[position]);
Bitmap bitmap = Bitmap.createScaledBitmap(tempbitMap,width,height, true);
full.setBackgroundDrawable(new BitmapDrawable((bitmap)));
String image_path = BitMapToString(bitmap);
Util.setBackgroundImagePath(getApplicationContext(),image_path);
WallpaperManager wallpaperManager= WallpaperManager.getInstance(FullImageActivity.this);
wallpaperManager.setWallpaperOffsetSteps(1, 1);
wallpaperManager.suggestDesiredDimensions(width, height);
try {
wallpaperManager.setBitmap(bitmap);
Toast.makeText(getApplicationContext(), "Done", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
}
}});
ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this);
full.setOnTouchListener(activitySwipeDetector);

public Bitmap StringToBitMap(String encodedString){
try{
byte [] encodeByte=Base64.decode(encodedString,Base64.DEFAULT);
Bitmap bitmap=BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length);
return bitmap;
}catch(Exception e){
e.getMessage();
return null;
}
}
public String BitMapToString(Bitmap bitmap){
ByteArrayOutputStream baos=new  ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG,100, baos);
byte [] b=baos.toByteArray();
String temp=Base64.encodeToString(b, Base64.DEFAULT);
return temp;

} }

here i am setting background to layoutif you have queries .. askhope this helps you

Read More

compress Method Overview
Write a compressed version of the bitmap to the specified outputstream.

Official android.graphics.Bitmap.compress documentation

See Also

copy
Tries to make a new bitmap based on the dimensions of this bitmap, setting the new bitmap's config to the one specified, and then copying this bitmap's pixels into the new bitmap.

copyPixelsFromBuffer
Copy the pixels from the buffer, beginning at the current position, overwriting the bitmap's pixels.

copyPixelsToBuffer
Copy the bitmap's pixels into the specified buffer (allocated by the caller).

createBitmap
Returns a immutable bitmap with the specified width and height, with each pixel value set to the corresponding value in the colors array.

createScaledBitmap
Creates a new bitmap, scaled from an existing bitmap, when possible.

eraseColor
Fills the bitmap's pixels with the specified Color.

extractAlpha
Returns a new bitmap that captures the alpha values of the original.

getByteCount
Returns the minimum number of bytes that can be used to store this bitmap's pixels.

getConfig
If the bitmap's internal config is in one of the public formats, return that config, otherwise return null.

getDensity
Returns the density for this bitmap.

getHeight
Returns the bitmap's height

getPixels
Returns in pixels[] a copy of the data in the bitmap.

getRowBytes
Return the number of bytes between rows in the bitmap's pixels.

getWidth
Returns the bitmap's width

hasAlpha
Returns true if the bitmap's config supports per-pixel alpha, and if the pixels may contain non-opaque alpha values.

isMutable
Returns true if the bitmap is marked as mutable (i.e. can be drawn into)

isRecycled
Returns true if this bitmap has been recycled.

recycle
Free the native object associated with this bitmap, and clear the reference to the pixel data.

writeToParcel
Write the bitmap and its pixels to the parcel.



Popular Android Classes

Fragment
(android.app.Fragment)

GridView
(android.widget.GridView)

Handler
(android.os.Handler)

ImageView
(android.widget.ImageView)

Intent
(android.content.Intent)

ListView
(android.widget.ListView)

MediaPlayer
(android.media.MediaPlayer)

SQLiteDatabase
(android.database.sqlite.SQLiteDatabase)

ScrollView
(android.widget.ScrollView)

Service
(android.app.Service)

Spinner
(android.widget.Spinner)

TextView
(android.widget.TextView)

Toast
(android.widget.Toast)

WebView
(android.webkit.WebView)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: