package com.loaderman.customviewdemo;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.ImageView; public class MainActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); Bitmap srcBmp = BitmapFactory.decodeResource(getResources(), R.drawable.dog);
ImageView iv1 = (ImageView) findViewById(R.id.img1);
iv1.setImageBitmap(srcBmp); Bitmap desBmp = srcBmp.copy(Bitmap.Config.ARGB_8888, true);
for (int h = 0; h < srcBmp.getHeight(); h++) {
for (int w = 0; w < srcBmp.getWidth(); w++) {
int originColor = srcBmp.getPixel(w, h); int red = (Color.red(originColor));
int alpha = Color.alpha(originColor);
int green = Color.green(originColor);
int blue = Color.blue(originColor); if (green < 200) {
green += 30;
} desBmp.setPixel(w, h, Color.argb(alpha, red, green, blue)); }
} ImageView iv2 = (ImageView) findViewById(R.id.img2);
iv2.setImageBitmap(desBmp);
} }

效果:

Bitmap之getPixel和setPixel函数的更多相关文章

  1. 解决 C# GetPixel 和 SetPixel 效率问题(转)

    在对Bitmap图片操作的时候,有时需要用到获取或设置像素颜色方法:GetPixel 和 SetPixel, 如果直接对这两个方法进行操作的话速度很慢,这里我们可以通过把数据提取出来操作,然后操作完在 ...

  2. bitMap算法实现以及ckHash函数类,将字符串映射成数字,同时可以将数字映射成字符串

    ckHash函数类,将字符串映射成数字,同时可以将数字映射成字符串 说明 1.所谓的BitMap就是用一个bit位来标记某个元素所对应的value,而key即是该元素,由于BitMap使用了bit位来 ...

  3. Bitmap之getDensity和setDensity函数

    package com.loaderman.customviewdemo; import android.app.Activity; import android.graphics.Bitmap; i ...

  4. DirectX中文手册

    目  录 第一章 DirectX基础(初级篇) 第一节  什么是DirectX 一.什么是DirectX ? 二.DirectX的组成部分 三.关于DirectDraw 四.为什么要使用DirectD ...

  5. (转)C#进行图像处理的几种方法(Bitmap,BitmapData,IntPtr)

    转自 http://blog.sina.com.cn/s/blog_628821950100wh9w.html C#进行图像处理的几种方法 本文讨论了C#图像处理中Bitmap类.BitmapData ...

  6. .net 反射访问私有变量和私有方法 如何创建C# Closure ? C# 批量生成随机密码,必须包含数字和字母,并用加密算法加密 C#中的foreach和yield 数组为什么可以使用linq查询 C#中的 具名参数 和 可选参数 显示实现接口 异步CTP(Async CTP)为什么那样工作? C#多线程基础,适合新手了解 C#加快Bitmap的访问速度 C#实现对图片文件的压

    以下为本次实践代码: using System; using System.Collections.Generic; using System.ComponentModel; using System ...

  7. 基于位图(Bitmap、BitmapData)的图片处理方法(C#)

    目前操作位图的主流方法有三种: 1.基于Bitmap像素的处理方法,以GetPixel()和SetPixel()方法为主.方法调用简单,但是效率偏低. 2.基于内存的像素操作方法,以System.Ru ...

  8. 加快Bitmap的访问速度

    引言 在对Bitmap图片操作的时候,有时需要用到获取或设置像素颜色方法:GetPixel 和 SetPixel, 如果直接对这两个方法进行操作的话速度很慢,这里我们可以通过把数据提取出来操作,然后操 ...

  9. 对索引像素格式的图片进行Setpixel(具有索引像素格式的图像不支持SetPixel)解决方案

    最近编写了一个验证码识别软件.其中对png.jpg图片进行二值化处理时,出现了错误:具有索引像素格式的图像不支持SetPixel解决方案.从字面上来看,这说明我对一个具有索引色的图片进行了直接RGB颜 ...

随机推荐

  1. STM32定时器配置(TIM1、TIM2、TIM3、TIM4、TIM5、TIM8)高级定时器+普通定时器,定时计数模式下总结

    文章结构: ——> 一.定时器基本介绍 ——> 二.普通定时器详细介绍TIM2-TIM5 ——> 三.定时器代码实例 一.定时器基本介绍  之前有用过野火的学习板上面讲解很详细,所以 ...

  2. 9.1: 请每个小组在 cnblogs.com 上面创建团队博客,第一个博客把小组成员都介绍一下 #团队博客作业1------------------答题者:徐潇瑞

    大家好,我们这个团队的名字叫14组之家,之所以这么叫,因为我们是在章亦葵老师的现代软件工程课上成立为14组,而且我们每个组员在这个小家庭中都感受到温暖,我们互相协作,互相配合,来完成我们的任务. 首先 ...

  3. unity之中级必备知识

    Mask,Scroll Rect实现图拖拽:新建Imag,添加Mask,Scroll Rect组件:新建Image,托放在Scroll下的Content:新建Scroll Bar实现滚动条的同步:托放 ...

  4. Codeforces Round #524 (Div. 2) Masha and two friends矩形

    题目 题意:    给一个n*m块大的黑白相间的矩形,在这个举行中操作,要先把第一个矩形(左下角坐标(x1,y2),右上角坐标(x2,y2)) 全部涂成白色,再把第二个矩形(左下角坐标(x3,y3), ...

  5. 【转】protocol buffer开发指南

    这个作者的其它golang的文章也值得一读 原文:https://www.cnblogs.com/charlieroro/p/9011900.html protocol buffer开发指南 ---- ...

  6. 七、Linq To XML:XElement、XDocument

    一.概述 LINQ to XMLLINQ to XML 是一种启用了 LINQ 的内存 XML 编程接口,使用它,可以在 .NET Framework.NET Framework 编程语言中处理 XM ...

  7. pandas 4

    参考资料:https://mp.weixin.qq.com/s/QnxaOrvlWJn6Dr42Ic1CcQ 1  #只选取housing,loan,contac和poutcometest_data[ ...

  8. django2.0报错Cannot import name 'urlresolvers'

    刚刚从django1.1迁移到django2.0中出现一个意外的报错: google 了下,在stack.overflow上解释是说django2.0 把原来的 django.core.urlreso ...

  9. AtCoder NIKKEI Programming Contest 2019 C. Different Strokes (贪心)

    题目链接:https://nikkei2019-qual.contest.atcoder.jp/tasks/nikkei2019_qual_C 题意:给出 n 种食物,Takahashi 吃下获得 a ...

  10. Vue 获取页面后跳转其他页面

    <template> <div> <img :src="detail.img" /> <h1>{{ detail.title }}& ...