bitmap

Manipulate an image without deleting its EXIF data

一个人想着一个人 提交于 2020-01-09 09:09:42
问题 Using imageIO, I usually have the problem of transforming an image file, and after overwriting it, it loses all of its EXIF data. Is there any way to preserve it without first extracting it, caching it, and then resetting it? 回答1: ImageIO do have this functionality itself, but instead of ImageIO.read you will need to use ImageReader: ImageReader reader = ImageIO.getImageReadersBySuffix("jpg").next(); (you may want to also check if such reader exists). Then you need to set the input: reader

How to resize image (Bitmap) to a given size? [duplicate]

筅森魡賤 提交于 2020-01-09 03:01:04
问题 This question already has answers here : How to Resize a Bitmap in Android? (15 answers) Closed 2 years ago . How to resize image (Bitmap) to for example 800*480 programatically ? I have retrieved a picture in my app which is ~1MB and I need to scale it down to 800*480 I have loaded that picture and compressed it but how do I do to make it smaller : ByteArrayOutputStream bos = new ByteArrayOutputStream(8192); photo.compress(CompressFormat.JPEG, 25, bos); 回答1: Bitmap scaledBitmap = scaleDown

Android Bitmap上绘制Bitmap

≡放荡痞女 提交于 2020-01-09 02:29:41
先说下我要解决的问题,如图,界面上的小图片能够随意拖动,背景的大图片可以放大(超过屏幕)也可以随意拖动,我现在要做的是将小图片的位置记录下来,放大大图片里形成一张新的图片而且要保证两张图片的相对位置和大小保持不变,花点时间实现这个效果: 1.背景图片的放大可拖动我使用的是Google提供的PhototView开源包,就在再这里展示了; 2.小图片的随意拖动,这个相信对大家来说都不是大问题,我附上自己写的,参考下: package com.example.androidhtmldemo; import android.app.Activity; import android.util.DisplayMetrics; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; /** * View随手势在屏幕上移动 * @author Administrator * */ public class OnViewMoveTouchListener implements OnTouchListener { private View imgView; private int lastX,lastY; private int left,right,top

How to attach image from drawable to gmail?

删除回忆录丶 提交于 2020-01-08 18:02:14
问题 I am trying to attach image from my gridview to gmail or facebook,but whenever i tried to attach my app got crash,and i am getting following error with nullpointer exception,following is my code with gridview image selection,can any one help? public class Free_Cover_Activity extends AppCompatActivity { GridView grid; int[] imageId = { R.drawable.discovercover, R.drawable.burpresswordfree, R.drawable.flyfree, R.drawable.cantmovefree, R.drawable.cantmovewordfree, R.drawable.chalkthisfree, R

自己写了个截图工具

不羁岁月 提交于 2020-01-08 09:40:49
很简单,就是先全屏截图,然后再按需要裁剪就可以了。 所以,首先要获取桌面的大小,代码如下: public class PrimaryScreen { #region Win32 API [DllImport("user32.dll")] static extern IntPtr GetDC(IntPtr ptr); [DllImport("gdi32.dll")] static extern int GetDeviceCaps( IntPtr hdc, // handle to DC int nIndex // index of capability ); [DllImport("user32.dll", EntryPoint = "ReleaseDC")] static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc); #endregion #region DeviceCaps常量 const int HORZRES = 8; const int VERTRES = 10; const int LOGPIXELSX = 88; const int LOGPIXELSY = 90; const int DESKTOPVERTRES = 117; const int DESKTOPHORZRES = 118; #endregion

Convert a bitmap into a byte array

流过昼夜 提交于 2020-01-08 09:31:40
问题 Using C#, is there a better way to convert a Windows Bitmap to a byte[] than saving to a temporary file and reading the result using a FileStream ? 回答1: There are a couple ways. ImageConverter public static byte[] ImageToByte(Image img) { ImageConverter converter = new ImageConverter(); return (byte[])converter.ConvertTo(img, typeof(byte[])); } This one is convenient because it doesn't require a lot of code. Memory Stream public static byte[] ImageToByte2(Image img) { using (var stream = new

转:Qt显示中文

末鹿安然 提交于 2020-01-08 00:50:01
也许是我用的系统太老,以前一直在换字符集以为能显示中文,看来还是字体的原因。 在安装了文泉驿以后终于可以显示中文啦。 先上 http://wenq.org/ 下个字体库,如:wqy-bitmapfont-pcf-0.9.9-0.tar.gz http://sourceforge.net/project/showfiles.php?group_id=128192&package_id=156288&release_id=551714 1 : 解压缩,tar zxvf,得到pcf文件 2:创建字体目录,mkdir -p /usr/share/fonts/mine/bitmap/wenquanyi 3:把字体拷贝到上面的目录 cp *.pcf /usr/share/fonts/mine/bitmap/wenquanyi 4 : fc-cache -f -v,这样使用fontconfig的程序就可以使用这个字体了,(一般都只需要到这一步, 然后跳到第七步)(下面几步我是照做) 如果还需要在X核心里面使用这个字体,需要进行下面的操作 5:mkfontdir 先到上面的目录去,cd /usr/share/fonts/mine/bitmap/wenquanyi 然后 mkfontdir ./ 生成一个fonts.dir cp fonts.dir fonts.scale 6:修改配置文件/etc

解决:Bitmap too large to be uploaded into a texture

前提是你 提交于 2020-01-07 17:45:24
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 简单说就是硬件加速的时候,对图片的大小有限制。不同设备可能有不同的最大值。这个问题悲催的地方是,程序貌似没有捕获到这个exception, 结果是程序也不报错,图片也显示不出来。只有看debug log才能发现这个error message. 一个解决的方法是禁止硬件加速,简单粗暴:有关 <application android:hardwareAccelerated="false" ...> 比较好的解决方法是类似google map的实现:将图片分成不同的块,每次加载需要的块。android提供了一个方法:( http://developer.android.com/reference/android/graphics/BitmapRegionDecoder.html ) public void drawBitmap (Bitmap bitmap, Rect src, RectF dst, Paint paint) public Bitmap decodeRegion (Rect rect, BitmapFactory.Options options) 采取上述操作后,就可以加载很多图片,同时也可以显示超级大图了。 来源: oschina 链接: https://my.oschina.net/u

Picture Puzzle: Set one Image to the same size and position to another image

别说谁变了你拦得住时间么 提交于 2020-01-07 16:35:09
问题 today I already asked you a question for my picture puzzle (Original Question). I started to rewrite my code for better performance. And I got the most important part done! But I have another problem.. I generate a gray overlay image to hide the image, but because I want to handle dynamic size of pictures I cannot set fixed width and height values for the "mask". So probably not the whole picture is overlayed with my "mask". Does somebody have a solution for this? I don't know how to set the

Copying bytes from Bitmap to byte array and back with Marshall.Copy doesn't work right

帅比萌擦擦* 提交于 2020-01-07 08:33:19
问题 I want to copy bytes with Marshall.Copy. My code work, but bytes is strange for me. I think, I got indexes not real bytes. If this compute and save back, I got different colors in image with lot bigger byte size (image size is same). Bitmap bmp = new Bitmap(imagepath); Width = bmp.Width; Height = bmp.Height; byte[] data; BitmapData bdata; switch (bmp.PixelFormat) { case PixelFormat.Format8bppIndexed: { data = new byte[Width * Height]; bdata = bmp.LockBits(new Rectangle(0, 0, Width, Height)