bitmap

IllegalArgumentException: x + width must be <= bitmap.width() in android

萝らか妹 提交于 2020-01-15 11:57:00
问题 I want to crop an image with in a margin (10,50,10,50),(left,top,right,bottom) respectively of an imageview. Here is my code Bitmap bitmap = Bitmap.createBitmap(imgView.getWidth(),imgView.getHeight(), Bitmap.Config.ARGB_8888); Bitmap result = Bitmap.createBitmap(bitmap, (imgView.getLeft() + 10), imgView.getTop() + 50,imgView.getRight() - 10,imgView.getBottom() - 50); bitmap.recycle(); Canvas canvas = new Canvas(result); imgView.draw(canvas); ie, if my imageview is of dimension 200X300.then i

Bitmap cache on DrawingVisual has blurry parts

喜夏-厌秋 提交于 2020-01-15 11:48:29
问题 Recently I switched to DrawingVisuals to increase the performance of our trending graphs (especially zooming and panning). Here's the code I have: blocksToBeRendered = (baseItem as AvgCurve).GetStreamGeometryBlocks(ActualWidth, ActualHeight, _minPoint.X, _maxPoint.X, FixTimeStep ? _timeStep : 0, IsMainChart); Pen stroke = new Pen((baseItem as AvgCurve).LineBrush, 1); foreach (GeometryGroup group in blocksToBeRendered) { if (group.Children.Count != 0) { if (!cachedBlocks[baseItem].Any(x => x

C# 图片转为Base64

大憨熊 提交于 2020-01-15 11:47:08
/// <summary> /// 图片转Base64 /// </summary> /// <param name="ImageFileName">图片的完整路径</param> /// <returns></returns> public static string ImgToBase64(string ImageFileName) { try { Bitmap bmp = new Bitmap(ImageFileName); MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] arr = new byte[ms.Length]; ms.Position = 0; ms.Read(arr, 0, (int)ms.Length); ms.Close(); return Convert.ToBase64String(arr); } catch (Exception) { return null; } } 来源: https://www.cnblogs.com/flamegreat/p/12195742.html

Android Canvas focus in selected area

北战南征 提交于 2020-01-15 10:54:23
问题 I'm trying to achieve this effect: The idea is that I want to cover an ImageView with a partial transparent layer, but not all of it. Somewhere there is an area (circle or rectangle), that should be completely transparent. I tried it using this lines of code: Paint paint = new Paint(); paint.setColor(Color.parseColor("#80000000")); canvas.drawRect(0, 0, bitmap.getWidth(), bitmap.getHeight(), paint); paint.setColor(Color.TRANSPARENT); canvas.drawCircle((int) x, (int) y, 50, paint); but it didn

Bitmap created from FrameLayout is black

纵然是瞬间 提交于 2020-01-15 10:36:09
问题 I am trying to create a bitmap for share intent.Bitmap is created( I hope because it is not null which it was when tried out buildDrawingCache() solution) but when it is shared it is null.I have looked at other SO answers also but none of them works. In my code you can see I have tried other solutions also but created bitmap is null there.Here at least the bitmap is created but it's black. My image is 500px X 500px image by the way if it matters. share_image.xml <?xml version="1.0" encoding=

A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll

让人想犯罪 __ 提交于 2020-01-15 07:35:09
问题 I'm trying to make a fullscreen screencapture and load it into an pictureBox, but it's giving me this error: A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll Additional information: Ongeldige parameter. Code: using (Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)) { using (Graphics g = Graphics.FromImage(bmpScreenCapture)) { g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen

Direct2D bitmap brush elongated

被刻印的时光 ゝ 提交于 2020-01-15 05:51:31
问题 I have to draw my shapes on a offscreen bitmap, but I have a strange problem when I try to render my bitmap. This is how the image should be displayed: And this how I a see the bitmap: Following is the code I use to create the bitmap brush: const auto size = renderTarget->GetSize(); const auto pxSize = D2D1::SizeU(size.width * 4, size.height * 4); ID2D1BitmapRenderTarget* compatibleRenderTarget; HRESULT hr = renderTarget->CreateCompatibleRenderTarget(size, pxSize, &compatibleRenderTarget); if

C#双缓冲绘图

自作多情 提交于 2020-01-15 04:25:28
一、 画面闪烁 问题与双缓冲技术 1.1 导致画面闪烁的关键原因分析: 1 绘制窗口由于大小位置状态改变进行重绘操作时   绘图窗口内容或大小每改变一次,都要调用Paint事件进行重绘操作,该操作会使画面重新刷新一次以维持窗口正常显示。刷新过程中会导致所有图元重新绘制, 而各个图元的重绘操作并不会导致Paint事件发生,因此窗口的每一次刷新只会调用Paint事件一次。 窗口刷新一次的过程中,每一个图元的重绘都会立即显示到窗口, 因此整个窗口中,只要是图元所在的位置,都在刷新,而刷新的时间是有差别的,闪烁现象自然会出现 。   所以说,此时导致窗口闪烁现象的关键因素并不在于Paint事件调用的次数多少,而在于各个图元的重绘。   根据以上分析可知,当图数目不多时,窗口刷新的位置也不多,窗口闪烁效果并不严重;当图元数目较多时,绘图窗口进行重绘的图元数量增加,绘图窗口每一次刷新 都会导致较多的图元重新绘制,窗口的较多位置都在刷新,闪烁现象自然就会越来越严重。特别是 图元比较大绘制时间比较长时 ,闪烁问题会更加严重,因为时间延迟会更长。 解决上述问题的关键在于 : 窗口刷新一次的过程中,让所有图元同时显示到窗口 。 2、 进行鼠标跟踪绘制操作或者对图元进行变形操作时    当进行鼠标跟踪绘制操作或者对图元进行变形操作时,Paint事件会频繁发生,这会使窗口的刷新次数大大增加

FindResource works, LoadBitmap doesn't, LoadImage from disk works

时光毁灭记忆、已成空白 提交于 2020-01-14 14:55:26
问题 I am trying to use LoadBitmap to load an image from a resource file. I've verified that the resource is linked correctly -- examining the final EXE with a hex editor shows that the bitmap is packed inside the EXE correctly. I've also verified that the bitmap is valid -- using LoadImage with LR_LOADFROMFILE to load the bitmap from disk at runtime works fine and I see it appear when I add it to a gui element later. I've verified that the ID that I use to access the resource is valid as well --

android bitmap pixel format for glTexImage2D

妖精的绣舞 提交于 2020-01-14 14:49:07
问题 I'm trying to load textures to use with NDK OpenGL from Java with the Bitmap class. It works, but I'm having problems with the pixel format. First, in Java, I load a bitmap from the assets folder like this: Bitmap bitmap = BitmapFactory.decodeStream(amgr.open(path)); return bitmap.copy(Bitmap.Config.ARGB_8888, false); the bitmap config does not have an option for RGBA channel order. [JNI things happen here] Using GLES 1, I then buffer the texture like so: glTexImage2D(GL_TEXTURE_2D, 0, GL