DAY 009:_PutImage - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: Official Links (https://staging.qb64phoenix.com/forumdisplay.php?fid=16) +--- Forum: Learning Resources and Archives (https://staging.qb64phoenix.com/forumdisplay.php?fid=13) +---- Forum: Keyword of the Day! (https://staging.qb64phoenix.com/forumdisplay.php?fid=49) +---- Thread: DAY 009:_PutImage (/showthread.php?tid=1119) |
RE: DAY 009:_PutImage - SMcNeill - 11-15-2022 And, don't forget, _PUTIMAGE can be used to invert and flip images. For example, read from left to right (0,0) - (_WIDTH, _HEIGHT) as the source, and then put it to the screen right to left (_WIDTH, _HEIGHT) - (0,0). It won't rotate images (for that, you need to use _MAP TRIANGLE), but it can be used fairly easy to mirror them. RE: DAY 009:_PutImage - bplus - 11-15-2022 Yeah this! Code: (Select All) Screen _NewImage(800, 600, 32) ' screen width, height, 32 is _RGBA colors And one last detail to Smooth out ;-)) I was hoping Steve might pickup on that RE: DAY 009:_PutImage - Pete - 11-15-2022 Yep, leave it to Steve to flip us the bird! Pete RE: DAY 009:_PutImage - james2464 - 11-15-2022 STEP is useful for stuff like this, for sure. Code: (Select All) 'checkerboard Nice to know about this. Now I wonder what "SMOOOTH" does... RE: DAY 009:_PutImage - SMcNeill - 11-15-2022 (11-15-2022, 04:20 AM)james2464 Wrote: Nice to know about this. Now I wonder what "SMOOOTH" does... From what I understand, SMOOTH basically just blends color values together to reduce such sharp transitions and edges in an image. For example, let's say I have an image where the red values look like this in a 3x3 block of pixels: 0,100,0 50,0,50 0,100,0 Now, that center pixel originally had a value of 0, but after we smooth it with all its surrounding pixels, we end up taking the average of whatever that value is. 0+ 100+ 0 + 50 + 0 + 50+0+100+0= 300 ... 300 / 9 = 33.333 So, not counting any smoothing of the rest of the pixels (as they'd smooth to blend in with their 8 neighbors), our color values would now look like: 0, 100, 0 50, <33>, 50 0, 100, 0 See where that value "smoothed" out so it isn't such a sharp change all at once in those values? Now, imagine drawing a white box on a black screen. 0,0,100 0,0,100 0,0,100 ^ 0 for the "NO white value" to start with, and 100 for "ALL white value". (Just cause it makes math easier than 255 does.) All those adjoining black edges (of the left side of the box) are going to be surrounded by the pattern showcased above. Add their neighbor's values and they're all going to end up being 300 / 9 = 33.33. For the white side of the box/screen border, what we'd see would be: 0,100,100 0,100,100 0,100,100 Which ends up basically being 600/9 = 66.66. So, at the end of the day, our box's edge no longer looks like: 0,0,100,100 0,0,100,100 0,0,100,100 0,0,100,100 It's now: 0,33,66,100 0,33,66,100 0,33,66,100 0,33,66,100 We smoothed out that hard edge and softened that transition from black to white. Now, of course, our QB64 _SMOOTH in putimage is working with RGBA colors from 0 to 255, and not just the simple black/white values that I used above from 0 to 100, but the basic concept is the same -- take one pixel and smooth it with its neighbors to reduce sharp edges and add gentler transitions to your image. RE: DAY 009:_PutImage - madscijr - 11-15-2022 (11-15-2022, 12:00 AM)bplus Wrote: Here is what it looks like in Wiki: I love what you're doing, covering QB64PE command by command! Question - are you going to cover hardware images too? It's been a number of months and I could use a refresher! :-) RE: DAY 009:_PutImage - james2464 - 11-15-2022 Sounds like an interesting feature...I'm going to try to mess around with it. So far I haven't been able to place the word _Smooth properly, not sure where it actually should go, if it needs brackets etc Edit: this works Code: (Select All) _PutImage (1, 1)-(101, 101), 0, image&, (1, 1)-(101, 101), _Smooth Now I'll try to see what the effect looks like! Thanks for taking the time to explain what it does. RE: DAY 009:_PutImage - SMcNeill - 11-15-2022 I just spent ages trying to work up an example which showcases the blending of the _SMOOTH command, only to have each and every one of them do nothing whatsoever. Frustrated, I finally dug into the libqb.cpp source to see what it tells us about this _SMOOTH... Code: (Select All) hgc->smooth = 0; // unless specified, no filtering will be applied It basically sets a flag for hgc.smooth to become true instead of false... And what is hgc iniside libqb? Hardware Graphic Control.... _SMOOTH *only* works with hardware images. It does nothing with software images. As most people tend to work exclusively with software images, _SMOOTH may as well not exist for them. It's not going to make one whit of a difference in how things look or display. RE: DAY 009:_PutImage - Pete - 11-15-2022 Thanks for _SMOOTHing things over. Pete RE: DAY 009:_PutImage - james2464 - 11-15-2022 (11-15-2022, 04:37 PM)SMcNeill Wrote: I just spent ages trying to work up an example which showcases the blending of the _SMOOTH command, only to have each and every one of them do nothing whatsoever. Hmm...that's a shame. I don't know enough about this (Hardware vs software image?) But anyway thanks for the info. |