在我的应用程序中,用户可以上传一些图片和数据库大小限制我想合并这些图像只创建一个图像,我这样做:
private Bitmap combineImageIntoOne(ArrayList<Bitmap> bitmap) {
int w = 0, h = 0;
for (int i = 0; i < bitmap.size(); i++) {
if (i < bitmap.size() - 1) {
w = bitmap.get(i).getWidth() > bitmap.get(i + 1).getWidth() ? bitmap.get(i).getWidth() : bitmap.get(i + 1).getWidth();
}
h += bitmap.get(i).getHeight();
}
Bitmap temp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(temp);
int top = 0;
for (int i = 0; i < bitmap.size(); i++) {
Log.d("HTML", "Combine: "+i+"/"+bitmap.size()+1);
top = (i == 0 ? 0 : top+bitmap.get(i).getHeight());
canvas.drawBitmap(bitmap.get(i), 0f, top, null);
}
return temp;
}
答案 0 :(得分:0)
public static function displayTweets( $count = 1) {
$key = "twitter-transient";
$cached = get_transient($key);
if (!$cached) {
$settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => "",
'consumer_secret' => ""
);
// Searches Tweets from the User
$url = 'https://api.twitter.com/1.1/statuses/user_timeline.json';
$getfield = '?screen_name=ipmPress&count=' . $count . '';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$tweets = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
$response = json_decode($tweets);
set_transient($key, $response, 1800);
$cached = $response;
}
// Gets Embed Response for the Collected Tweets
foreach ($cached as $tweet) {
$url = 'https://api.twitter.com/1.1/statuses/oembed.json';
$getfield = '?id=' . $tweet->id . '&omit_script=true&hide_media=true';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$tweets = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
$response = json_decode($tweets);
echo
'<div class="large-4 medium-6 column">' .
$response->html .
'</div>';
}
}
是您要查找的方法 - 它允许您将Bitmap.compress
保存到您想要的任何Bitmap
。
OutputStream