bitmap

ImageView: automatically recycle bitmap if ImageView is not visible (within ScrollView)

房东的猫 提交于 2020-01-01 04:57:08
问题 So, I've been looking at the ImageView source for a while, but I haven't figured out a hook to do this yet. The problem: having, let's say, 30 400x800 images inside a ScrollView (the number of images is variable). Since they fit exactly in the screen they will take 1.3 MB of RAM each. What I want: to be able to load/unload bitmaps for the ImageViews that are currently visible inside a ScrollView. If the user scrolls and the bitmap is no longer visible (within a distance threshold) the bitmap

Android Opengl-es loading a non-power of 2 texture

懵懂的女人 提交于 2020-01-01 04:38:06
问题 I have an app that I've been repeatedly playing with in android, it uses opengl-es. Currently I load textures from a bitmap like so: //Load up and flip the texture - then dispose the temp Bitmap temp = BitmapFactory.decodeResource(Deflecticon.getContext().getResources(), resourceID); Bitmap bmp = Bitmap.createBitmap(temp, 0, 0, temp.getWidth(), temp.getHeight(), flip, true); temp.recycle(); //Bind the texture in memory gl.glBindTexture(GL10.GL_TEXTURE_2D, id); //Set the parameters of the

Memory usage does not decrease even I recycle bitmaps

可紊 提交于 2020-01-01 03:37:08
问题 I have A and B activities. When I start activity B from activity A, I set static bitmap variable on activity B. I show that bitmap on the screen and rotate it. When activity B is finished, I recycle all bitmaps on onDestroy() method but memory usage is not decreasing. @Override protected void onDestroy() { super.onDestroy(); if (bitmap90 != null) { bitmap90.recycle(); bitmap90 = null; } if (bitmap180 != null) { bitmap180.recycle(); bitmap180 = null; } if (bitmap270 != null) { bitmap270

How to create a square bitmap from a rectangular bitmap in Android

南笙酒味 提交于 2020-01-01 03:27:08
问题 Basically, I have a rectangular bitmap and want to create a new Bitmap with squared dimensions which will contain the rectangular bitmap inside of it. So, for example, if the source bitmap has width:100 and height:400, I want a new bitmap with width:400 and height:400. Then, draw the source bitmap centered inside of this new bitmap (see attached image for a better understanding). My code below creates the square bitmap fine, but the source bitmap is not being drawn into it. As a result, I'm

WPF - Graphics.CopyFromScreen returns a black image

前提是你 提交于 2020-01-01 02:33:28
问题 The following method is taken from a WinForms app. It simply captures the screen, but I needed to modify it to work in a WPF application. When I use it, it returns a black image. The dimensions are correct. I have not got any open DirectX or videos and it wouldn't work even on my desktop. public static Bitmap CaptureScreen() { // Set up a bitmap of the correct size Bitmap CapturedImage = new Bitmap((int)SystemParameters.VirtualScreenWidth, (int)SystemParameters.VirtualScreenHeight, System

android share image in ImageView without saving in sd card

五迷三道 提交于 2020-01-01 02:28:34
问题 I want to Share the image in image view.but i don't want save to SDcard. But when i use Intent to share i used code Intent share = new Intent(Intent.ACTION_SEND); share.setType("image/jpeg"); share.putExtra(Intent.EXTRA_STREAM,Uri.parse(path)); startActivity(Intent.createChooser(share, "Share Image")); here Path specified location of image in sdcard but i don't want save image ... is there possible .. 回答1: You could also share it as the Media Gallery content provider URI (if the image is

C++ CBitmap,HBitmap,Bitmap区别及联系

元气小坏坏 提交于 2020-01-01 01:25:13
加载一位图,可以使用LoadImage: HANDLE LoadImage(HINSTANCE hinst,LPCTSTR lpszName,UINT uType,int cxDesired,int CyDesired,UINT fuLoad); LoadImage可以用来加载位图,图标和光标 加载时可以规定加载图的映射到内存的大小: cxDesired:指定图标或光标的宽度,以像素为单位。如果此参数为零并且参数fuLoad值中LR_DEFAULTSIZE没有被使用,那么函数使用目前的资源宽度。  cyDesired:指定图标或光标的高度,以像素为单位。如果此参数为零并且参数fuLoad值中LR_DEFAULTSIZE没有被使用,那么函数使用目前的资源高度。 LoadImage的返回值是相关资源的 句柄。因为加载的是位图所以返回的句柄是HBITMAP型的(需要强制转换)。 延伸理解 HBITMAP/CBitmap/BITMAP: HBITMAP 是bitmap的指针, msdn中如是:Handle to a bitmap.typedef HANDLE HBITMAP; CBitmap 是mfc中封装bitmap的类; msdn中: Encapsulates(囊括) a Windows graphics device interface (GDI) bitmap and

GDI 总结三: CImage类使用

我只是一个虾纸丫 提交于 2020-01-01 01:23:53
前言 CImage类是基于GDI+的。可是这里为什么要讲归于GDI? 主要是基于这种考虑: 在GDI+环境中,我们能够直接使用GDI+ ,没多少必要再使用CImage类 可是,假设再GDI环境中,我们要想使用GDI+,有点麻烦。还得增加头文件。增加启动GDI+的代码和关闭GDI+的代码,显得太罗嗦了。GDI 的CBitmap 处理功能又有局限,仅仅能处理BMP格式的图片。 怎么办?这时。我们便可使用CImage类,由于这个类本身封装了GDI+得使用环境,所以无需我们手动设置,简化了我们的操作。 同一时候。又能够利用GDI+中强大的图片处理功能,及能够简便的与CBitmap对象进行转换 ,大慷慨便了在GDI环境下。进行各种图片处理工作 。 事实上,将其称作 GDI/ GDI+ 混合编程,这样才更确切些。 为什么引入CImage类? CBitmap 类仅仅能处理BMP格式的图片,很受限。 而CImage能够处理JPGE GIF BMP PNG多种格式图片,扩展了图片处理功能 且能与CBitmap 进行转换( 由于所加载的位图句柄都是HBITMAP,所以可相互转换),因此引入CImage类进行图像处理 CImage provides enhanced bitmap support, including the ability to load and save images in JPEG

关于CBitmap,LoadBitmap 的使用

二次信任 提交于 2020-01-01 01:22:55
在初始化CBitmap对象时,常用Cbitmap::LoadBitmap,即如下两种: BOOL LoadBitmap( LPCTSTR lpszRecourceName ); BOOL LoadBitmap( UINT nIDResource ); MSDN中的说明为: " 返回值调用成功时返回非零值,否则为0。 lpszResourceName指向一个包含了位图资源名字的字符串(该字符串以null结尾)。NIDResource指定位图资源中资源的ID号。说明本函数从应用的可执行文件中加载由lpszResourceName指定名字或者由nIDResource指定的ID号标志的位图资源。加载的位图被附在Cbitmap对象上。如果由lpszResourceName指定名字的对象不存在,或者没有足够的内存加载位图,函数将返回0。可以调用函数CgdiObject::DeleteObject删除由LoadBitmap加载的位图,否则Cbitmap的析构函数将删除该位图对象。警告 在删除位图对象之前,要保证它没有被选到设备上下文中。在Windows3.1以及以后的版本中,增加了如下的位图:OBM_UPARROWIORM_DNARROWIOBM_RGARROWIOBM_LFARROWI ......" 刚开始用的时候,我直接把图像路径名给了 lpszRecourceName,可总是不成功

Getting pixel format from CGImage

佐手、 提交于 2019-12-31 22:27:15
问题 I understand bitmap layout and pixel format subject pretty well, but getting an issue when working with png / jpeg images loaded through NSImage – I can't figure out if what I get is the intended behaviour or a bug. let nsImage:NSImage = NSImage(byReferencingURL: …) let cgImage:CGImage = nsImage.CGImageForProposedRect(nil, context: nil, hints: nil)! let bitmapInfo:CGBitmapInfo = CGImageGetBitmapInfo(cgImage) Swift.print(bitmapInfo.contains(CGBitmapInfo.ByteOrderDefault)) // True My