NinthDesertDude Posted April 3, 2016 Share Posted April 3, 2016 (edited) Download here (too large to attach): Brush Factory (Beta) Brush Factory allows you to draw brushes with basic dynamics, like randomized scaling, rotation, and transparency. Example below. It works well on images that are absolutely opaque. But, if the image has any transparency at all, it begins to cause strange errors. Consider this. Notice the obvious gray border around the white brush stroke on the second image. That shouldn't happen. These colors are actually darker (they are not white anymore, and it's not the alpha making it look gray there). This exact type of error occurs when you simply open/close the dialog, undo/redo, and draw over transparent regions. It can be hard to see esp. when simply opening and OKing the dialog, but it's there, so don't use Brush Factory with transparency. Anyway, I'd love to get help with fixing this GDI+ issue. I've been here: http://stackoverflow.com/questions/6615340/color-value-with-alpha-of-zero-shows-up-as-black http://stackoverflow.com/questions/15956424/gdi-bug-anti-aliasing-white-on-transparency http://stackoverflow.com/questions/1861305/c-sharp-resized-images-have-black-borders http://stackoverflow.com/questions/1890605/ghost-borders-ringing-when-resizing-in-gdi http://stackoverflow.com/questions/2024757/how-to-solve-grayish-frame-issue-when-scaling-a-bitmap-using-gdi http://stackoverflow.com/questions/6744067/drawimage-function-over-winforms-does-not-work-correctly http://www.codeproject.com/Articles/14884/BorderBug I read that there is a Border Bug where resized images include pixels outside the image, which are assumed Black, and involve them in the calculation (resulting in blackened borders). I read that creating a new bitmap automatically premultiplies each pixel by its alpha, so I've tried a tested workaround that locks the bits and copies them over (to avoid multiplying by alpha), but this doesn't solve my issue. I've tried all the solutions presented here, which I summarize below: - Any combination of InterpolationMode.NearestNeighbor, SmoothingMode.None, and PixelOffsetMode.Half. - Clearing with a transparent color, Color.White, and Color.Black, along with the above attempts as well. - Workarounds for cloning bitmaps, sometimes in conjunction with other workarounds above. - Using an ImageAttributes object and setting WrapMode to TileFlipXY, sometimes in conjunction with above workarounds. I've attached the source code along with the .dll. Please try to help if you can! Otherwise, I'll have no choice but to port the entire thing to another graphics library that doesn't have these silly errors and it'll take ages. Feel free to point out any side bugs so I can fix them too; I know a few of them already but am focusing on this now. Thanks. Download here (too large to attach): Brush Factory (Beta) Edited December 9, 2016 by AnthonyScoffler Replaced dead links with permanent links on google drive 2 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.