Jump to content

Bleek II

Members
  • Posts

    82
  • Joined

  • Last visited

Everything posted by Bleek II

  1. I was asked to make a to make a blur that would blur pixel based on it's luma value. The only source code I could find for blurring was the GaussianBlurEffect.cs built into paint.net although I wanted to use Ed Harvey's "True Blur" effect but could find it's source. Here is what I have. I don't even know what's going on so it's all screwed up and causes paint.net to crash. protected override unsafe void OnRender(Rectangle[] rois, int startIndex, int length) { Surface dst = DstArgs.Surface; Surface src = SrcArgs.Surface; /* ColorBgra col = SrcArgs.Surface[0, 0]; int luma = (int)(col.R * 0.3 + col.G * 0.59 + col.B * 0.11); int r = col.B; int[] w = CreateGaussianBlurRow(r); int wlen = w.Length; int localStoreSize = wlen * 6 * sizeof(long); byte* localStore = stackalloc byte[localStoreSize]; byte* p = localStore; long* waSums = (long*)p; p += wlen * sizeof(long); long* wcSums = (long*)p; p += wlen * sizeof(long); long* aSums = (long*)p; p += wlen * sizeof(long); long* bSums = (long*)p; p += wlen * sizeof(long); long* gSums = (long*)p; p += wlen * sizeof(long); long* rSums = (long*)p; p += wlen * sizeof(long); ulong arraysLength = (ulong)(sizeof(long) * wlen); */ int x = 0; for (int ri = startIndex; ri < startIndex + length; ++ri) { Rectangle rect = rois[ri]; if (rect.Height >= 1 && rect.Width >= 1) { for (int y = rect.Top; y < rect.Bottom; ++y) { ColorBgra col = SrcArgs.Surface[x, y]; int luma = (int)(col.R * 0.3 + col.G * 0.59 + col.B * 0.11); int r = luma; int[] wYL = CreateGaussianBlurRow(r); int wlen = wYL.Length; int localStoreSize = wlen * 6 * sizeof(long); byte* localStoreYL = stackalloc byte[localStoreSize]; byte* pYL = localStoreYL; long* waSumsYL = (long*)pYL; pYL += wlen * sizeof(long); long* wcSumsYL = (long*)pYL; pYL += wlen * sizeof(long); long* aSumsYL = (long*)pYL; pYL += wlen * sizeof(long); long* bSumsYL = (long*)pYL; pYL += wlen * sizeof(long); long* gSumsYL = (long*)pYL; pYL += wlen * sizeof(long); long* rSumsYL = (long*)pYL; pYL += wlen * sizeof(long); ulong arraysLength = (ulong)(sizeof(long) * wlen); // Memory.SetToZero(localStore, (ulong)localStoreSize); long waSum = 0; long wcSum = 0; long aSum = 0; long bSum = 0; long gSum = 0; long rSum = 0; ColorBgra* dstPtr = dst.GetPointAddressUnchecked(rect.Left, y); for (int wx = 0; wx < wlen; ++wx) { int srcX = rect.Left + wx - r; waSumsYL[wx] = 0; wcSumsYL[wx] = 0; aSumsYL[wx] = 0; bSumsYL[wx] = 0; gSumsYL[wx] = 0; rSumsYL[wx] = 0; if (srcX >= 0 && srcX < src.Width) { for (int wy = 0; wy < wlen; ++wy) { int srcY = y + wy - r; if (srcY >= 0 && srcY < src.Height) { ColorBgra c = src.GetPointUnchecked(srcX, srcY); int wp = wYL[wy]; waSumsYL[wx] += wp; wp *= c.A + (c.A >> 7); wcSumsYL[wx] += wp; wp >>= 8; aSumsYL[wx] += wp * c.A; bSumsYL[wx] += wp * c.B; gSumsYL[wx] += wp * c.G; rSumsYL[wx] += wp * c.R; } } int wwx = wYL[wx]; waSum += wwx * waSumsYL[wx]; wcSum += wwx * wcSumsYL[wx]; aSum += wwx * aSumsYL[wx]; bSum += wwx * bSumsYL[wx]; gSum += wwx * gSumsYL[wx]; rSum += wwx * rSumsYL[wx]; } } wcSum >>= 8; if (waSum == 0 || wcSum == 0) { dstPtr->Bgra = 0; } else { int alpha = (int)(aSum / waSum); int blue = (int)(bSum / wcSum); int green = (int)(gSum / wcSum); int red = (int)(rSum / wcSum); dstPtr->Bgra = ColorBgra.BgraToUInt32(blue, green, red, alpha); } ++dstPtr; for (x = rect.Left + 1; x < rect.Right; ++x) { col = SrcArgs.Surface[x, y]; luma = (int)(col.R * 0.3 + col.G * 0.59 + col.B * 0.11); r = luma; int[] wXL = CreateGaussianBlurRow(r); wlen = wXL.Length; localStoreSize = wlen * 6 * sizeof(long); byte* localStoreXL = stackalloc byte[localStoreSize]; byte* pXL = localStoreXL; long* waSumsXL = (long*)pXL; pXL += wlen * sizeof(long); long* wcSumsXL = (long*)pXL; pXL += wlen * sizeof(long); long* aSumsXL = (long*)pXL; pXL += wlen * sizeof(long); long* bSumsXL = (long*)pXL; pXL += wlen * sizeof(long); long* gSumsXL = (long*)pXL; pXL += wlen * sizeof(long); long* rSumsXL = (long*)pXL; pXL += wlen * sizeof(long); arraysLength = (ulong)(sizeof(long) * wlen); for (int i = 0; i < wlen - 1; ++i) { waSumsXL[i] = waSumsXL[i + 1]; wcSumsXL[i] = wcSumsXL[i + 1]; aSumsXL[i] = aSumsXL[i + 1]; bSumsXL[i] = bSumsXL[i + 1]; gSumsXL[i] = gSumsXL[i + 1]; rSumsXL[i] = rSumsXL[i + 1]; } waSum = 0; wcSum = 0; aSum = 0; bSum = 0; gSum = 0; rSum = 0; int wx; for (wx = 0; wx < wlen - 1; ++wx) { long wwx = (long)wXL[wx]; waSum += wwx * waSumsXL[wx]; wcSum += wwx * wcSumsXL[wx]; aSum += wwx * aSumsXL[wx]; bSum += wwx * bSumsXL[wx]; gSum += wwx * gSumsXL[wx]; rSum += wwx * rSumsXL[wx]; } wx = wlen - 1; waSumsXL[wx] = 0; wcSumsXL[wx] = 0; aSumsXL[wx] = 0; bSumsXL[wx] = 0; gSumsXL[wx] = 0; rSumsXL[wx] = 0; int srcX = x + wx - r; if (srcX >= 0 && srcX < src.Width) { for (int wy = 0; wy < wlen; ++wy) { int srcY = y + wy - r; if (srcY >= 0 && srcY < src.Height) { ColorBgra c = src.GetPointUnchecked(srcX, srcY); int wp = wXL[wy]; waSumsXL[wx] += wp; wp *= c.A + (c.A >> 7); wcSumsXL[wx] += wp; wp >>= 8; aSumsXL[wx] += wp * (long)c.A; bSumsXL[wx] += wp * (long)c.B; gSumsXL[wx] += wp * (long)c.G; rSumsXL[wx] += wp * (long)c.R; } } int wr = wXL[wx]; waSum += (long)wr * waSumsXL[wx]; wcSum += (long)wr * wcSumsXL[wx]; aSum += (long)wr * aSumsXL[wx]; bSum += (long)wr * bSumsXL[wx]; gSum += (long)wr * gSumsXL[wx]; rSum += (long)wr * rSumsXL[wx]; } wcSum >>= 8; if (waSum == 0 || wcSum == 0) { dstPtr->Bgra = 0; } else { int alpha = (int)(aSum / waSum); int blue = (int)(bSum / wcSum); int green = (int)(gSum / wcSum); int red = (int)(rSum / wcSum); dstPtr->Bgra = ColorBgra.BgraToUInt32(blue, green, red, alpha); } ++dstPtr; } } } } } } }
  2. Please note that they let you download higher rez versions to the right of the streaming video. http://bitcast-a.bitgravity.com/revisio ... d.h264.mov That's a link to the HD one but if your comp can't handle HD video they also have a "large" size versions.
  3. That's awesome, drew! I'm happy to see it working as well as its photoshop counterpart. I've just added a bit more control which may come in handy for some. I've haven't started work on adding anti-aliasing. BoltBait, could you point out a similar piece of code that has anti-aliasing in it so I can more easily translate it to this plugin, that would be most helpful. Thanks all!
  4. This is great, I'd been hope it would become a default part of paint.net for some time now but a plugin works too. One of the main things I would like to see is an update manager in it. It could connect to to a list online and check each Dll's version. Getting the online connection part to work would be hard I think... In short, I want a plugin manager that can do the stuff the one in firefox can. Although I understand it would require a commitment from the core team to setup a online service, I think that PDN deserves such a service. If it wasn't for the plugins here, artists like myself wouldn't be able to use PDN as a primary tool. This plugin is a huge step in the right direction for PDN, great job and thank you!
  5. Okay, I've uploaded a fixed Dll. I missed four little lines. It was dumb of me not to test the Dll on an image before release. But I'd like to see Microsoft have a 10min response time, haha I think not (*feels a little bit better about looking stupid*)
  6. I believe that's why he showed the code to you but do be sure to give credit. After all, this is a open source community. Nice plugin by the way, I've already found it to be useful.
  7. This is a great plugin! Very much like one I use to use in GIMP... only better! Would it be possible to increase the control range from 0-200 to 0-255?
  8. I've updated the plugin as asked by many users. I thank you all for the support!
  9. If that's a complied plugin, please post! However I believe that's an image edit, right? The reason those bar are so large is because I didn't want to spend the time figuring out how to get those nice input boxes next to the bars in windows form builder. So to give the user more control... I made them huge!... yeah I'm lazy, also I have my laptop screen here set at 1600x1050 so it's not to bad for me.
  10. The plugin is finished, thanks for all the help. viewtopic.php?f=16&t=24491
  11. Good points. This was the first time I used the windows form builder in VS 2008. I'm use to text based c++ programing. About the % based distortion, it really works best that way. I'll explain. The plugin reads each of the map's pixel luminosity values ranging from 0 to 255. The closer that value is to 0 the more it moves it in one direction and closer to 255 it is the more it moves it to the other direction, 127 is neutral. At 100% it moves each pixel the range value that's on the map but that's a bit of over kill in most cases so % works well to tune the process. However, in most cases I agree, I like to know how many pixels things are moving by. You can think of it as a range in this case 100% = -128 to 128, 50% = 64 to 64, and so on... The source code is there if you would like a better UI, I am lazy. I will post any updates to the plugin that others make and add you to the credits.
  12. The plugin distorts an image based on the light values of the mask. This is useful for mapping images to other surfaces. Alpha-Displacement Mask.zip Before After!!! Follow the this link for more on displacement (highly recommended) https://archive.org/details/pixelperfect/pixelperfect--0017--displacement--hd720p30.h264.mp4 ^^Don't miss the video^^ it's been here from the start. high rez downloads to the right of the stream https://forums.getpaint.net/topic/12895-create-a-waving-flag-using-displacement/^^Also read Drew's Paint.NET version!!^^ product below (Japanese) http://paintnet.web.fc2.com/plugin/okikae/admask.htm This plugin is based off the the AlphaMaskImport plugin. Credits pleska: File Handling Illnab1024: Alpha Mask MadJik: Coding help (lots of it) Bleek II: Displacement V1.0 release V1.1 UI: - smaller form - reset buttons - number boxes V1.1.1 -UI issue fixed V1.1.1.1 -fixed 1 off bug V1.2.0.0 -Added neutral value control v1.2.1.0 -fixed backwards neutral value -UI update -faster & cleaner displacement code v1.3.0.0 -edge controls v1.3.0.1 -UI font colors weren't the same on every system v1.4.1.1 -fixed dumb issues in 1.4.0.* -You can now clip with the alpha values of masks Also see: My gallery: https://forums.getpaint.net/topic/9003-bleek-iis-galleryupdated-61108/ ScreenPixel(a not very useful plug in): https://forums.getpaint.net/topic/9059-screenpixel/ ========================================================================== Edit by Ash: Seems people usually don't read all the way to page3. My easy to understand tips about this useful plugin.
  13. This is an update bump. 1-The desert speeder image is finished, CHECK IT OUT!!! 2-Gallery has a bit of an improved format... too lazy to make it any better Thanks to all who have replied here, all have been very nice. I would like to get more detailed feedback, like what do or do not like about any of the items. However if you just just want to say how much you love the work here, feel free; I like the feel good candy too .
  14. Once a month update bump! I'll be working on finishing the "Dez" for next month and more!! I'm also thinking about make this gallery a little easier on the eyes, but that's not a the top of my todo list right now.
  15. I'm giving this gallery a bum because it's seems to have disappeared. I mean totally disappeared. It was no where to be found on any page of The Pictorium. Can anyone explain this? Anyway, there's been a update since the last post. I hope this works. Update: I was using the FireFox find tool to search for the topic and now that I know where it is the find tool still can't find it. Maybe I just missed it when I used my I eyes but I really couldn't find it.... whatever....I'll see if someone else can find it next time, haha. Sorry about the bump people.
  16. Thanks. I also want to show an example where it can make a fun green screen effect when you play with the curves. Just like all those awesome 80s action films..... Snake!!!!!
  17. MODERATORS NOTE: this plugin has been superseded by a newer version: https://forums.getpaint.net/topic/31570-screen-pixel-v11-feb-24-2015/ This is a simple plugin made in Code Lab. It's made to be used along side the "Pixelate" effect: although it can be used by itself. Recommended use(example): 1: Apply Pixelate at any setting that can be divided by 3: like 3,6,9,12,15... and so 2: Apply ScreenPixel at 1/3 the value you applied Pixelate at and you're done. ScreenPixel will break each block into thirds for each RGB value. If used in this way it will have the intended effect; however you may find it useful by itself. Examples of Screenpixel: Step1 Step2 Another example can be found as the 5th image here at my "gallery": viewtopic.php?f=26&t=23561 Maybe when I get some extra time, I'll make a plugin that can stand on its own. I'm work on a very important simple displacement plugin on the side that will come first. I'd also like to thank MadJik for all the programing help and time, when displacement is finished will not have happened without Madjik. ScreenPixel.zip SPSource.zip
  18. You are very right. It's just a fun idea like a cow with wings carrying a knight into battle.
  19. That's a good bit of code, MadJik. I wish it was what I wanted but it's an entirely different effect. The effect the I envisioned would be the Pixelate effect only it split each block into three part. What you're made is like an overlay. The original code almost work but as the topic of this thread points out I had an issue with the y variable not taking the right steps in it's for loop. And as was pointed out by pyrochild I've spent this whole time, with your help, trying to find a work around for that. But any code that I've made is either broken or does the very same thing as the first code. In the end I know that I should find a more advanced way of doing to, like the Pixelate effect. But that's beyond me right now. I was so close this time but PDN's API has beaten me again. Thank you for you help, MadJik.
  20. You may want to click on the "full size" link above the images. And thank you, all.
  21. yes let me give two examples. Image1 .PNG=1.49MB .7z=847KB Image2 .PNG=6.19MB .7z=1.57MB
  22. I had an idea to use an existing lossless compression format for images. This is not a request as I can get along without it and I don't plan on making it myself. I've found that the smallest lossless file I can get is not even an image format at all. Using 7zip (http://www.7-zip.org/, most know of it) I am able to save 24bit .BMP files and take them down to a .7z file that is 60% to 20% the size of a .PNG file. I know I can't save alpha values this way but maybe a plugin based on 7zip could. I don't know there is a way for someone to call upon 7zip using a plugin or make it part of one but it's an idea. I don't need this plugin with over 300GB of storage but I thought someone might care to grab this bull by the horns, so to speak.
×
×
  • Create New...