Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DAY 009:_PutImage
#31
Suppose you want to use _PUTIMAGE _SMOOTH to blur an image....more than once...

Would this be possible? If so, how would you go about it? Based on my understanding, this seems impossible but I could be wrong. I attempted it and failed so I thought I'd ask.
Reply
#32
(11-16-2022, 03:48 AM)james2464 Wrote: Suppose you want to use _PUTIMAGE _SMOOTH to blur an image....more than once...

Would this be possible?  If so, how would you go about it?  Based on my understanding, this seems impossible but I could be wrong.  I attempted it and failed so I thought I'd ask.

I honestly don't think you can, since hardware images aren't alterable, so you're not going to _SMOOTH them.   I think it's basically going to be a onetime process, with you having to write your own smooth routine in case you want to process the same image multiple times.
Reply
#33
(11-16-2022, 03:55 AM)SMcNeill Wrote:
(11-16-2022, 03:48 AM)james2464 Wrote: Suppose you want to use _PUTIMAGE _SMOOTH to blur an image....more than once...

Would this be possible?  If so, how would you go about it?  Based on my understanding, this seems impossible but I could be wrong.  I attempted it and failed so I thought I'd ask.

I honestly don't think you can, since hardware images aren't alterable, so you're not going to _SMOOTH them.   I think it's basically going to be a onetime process, with you having to write your own smooth routine in case you want to process the same image multiple times.

Thanks.  Yeah I was kind of hoping there was a way to capture the blurred image but this confirms it.   That layer is basically untouchable, and can't be saved and brought back for more rounds of alteration.   Trying to get my mind around this, haha.
Reply
#34
It *can* be, but it's a lot of OpenGL and C-header stuff, from what I remember. Asiash (I'm certain I spelled it wrong), had a working example of reading from the hardware image over at the old forums somewhere, so it's not 100% impossible to do. It's just not something that 99.9998% of the user base is going to want to climb that deep into the rabbit hole to sort out how to do.

If you're in that minute group who's interested in sorting it out inside QB64, I wish you well in your endeavor. Gathering info back from a hardware image isn't something that I've ever personally attempted to do in QB64, so you've hit the limits of my personal knowledge and ability to help.

Do I know that *OTHER* people can do it?

YEP! YEP!! Sure do!

Does that mean I have a clue how to do it?

NOPE! Not at all. LOL!

Steve isn't a complete idiot, but he's also not the keeper of all knowledge either. Big Grin
Reply
#35
Nah, not something I'd be interested in.   I like the smooth/blur effect and wondered if this could be increased just by copying it back into another image header by capturing what's on the screen.   But the idea that hardware images aren't really there to be seen by the software side, that started to seem like maybe I just didn't understand it completely.   But alas it is what it is.   I think making a blur algorithm would be a good challenge.
Reply
#36
(11-16-2022, 03:48 AM)james2464 Wrote: Suppose you want to use _PUTIMAGE _SMOOTH to blur an image....more than once...

Would this be possible?  If so, how would you go about it?  Based on my understanding, this seems impossible but I could be wrong.  I attempted it and failed so I thought I'd ask.

Sure possible (not thinking with _PutImage and Smooth), several ways take average of 8 pixels surrounding pixel in question. Can do it it over and over until all one color.
Or take average of more and more neighbor pixels.

You would do this by hand calculations pixel by pixel. This is pretty much how Steve described how Smooth worked.
b = b + ...
Reply
#37
@bplus thanks for the keyword of the day series, it's great.

Quote:STEP allows you to use the last graphics command (x, y) as the start for the next graphics, a very handy use of step for images is to start with the (x,y) location of the top left corner of the rectangle and -Step(ImageWidth, ImageHeight) instead of adding width to x height to y and finding the absolute position value for the 2nd (x, y).
Could you help elaborate on this part:

Quote:a very handy use of step for images is to start with the (x,y) location of the top left corner of the rectangle and -Step(ImageWidth, ImageHeight) instead of adding width to x height to y and finding the absolute position value for the 2nd (x, y).
Could you possibly show me an example where we are using the absolute position value for the 2nd (x, y) and then how step would fix it?

Thanks
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#38
(11-15-2022, 03:25 AM)Pete Wrote: Yep, leave it to Steve to flip us the bird!

Pete

LOL!!!
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#39
Quote:Could you possibly show me an example where we are using the absolute position value for the 2nd (x, y) and then how step would fix it?

From our very recent code rewrite for FONT.print
Code: (Select All)
Sub F0NT.print (s$, f() As F0NT, x%, y%, scale%, spacing%)
  Dim As Integer i, l, dx1, dy1, dx2, dy2, orig_x
  Dim c As String
  Dim g As Long
  l% = Len(s$)
  ' PSet (x%, y%)
  For i% = 1 To l%
    c$ = Mid$(s$, i%, 1)
    'g& =
    '_Source g&
    dx1% = x% + (i% - 1) * (COLS + spacing%) * scale%
    dy1% = y%
    'dx2% = (COLS * scale%) + dx1%  ' << STEP allows us to leave off the dx1% from which we STEP
    'dy2% = (ROWS * scale%) + dy1%  ' << STEP allows us to leave off the dx2% from which we STEP
    '_PutImage (dx1%, dy1%)-(dx2%, dy2%), F0NT.get_glyph(c$, f())
    _PutImage (dx1%, dy1%)-Step(COLS * scale% - 1, ROWS * scale% - 1), F0NT.get_glyph(c$, f())
  Next i%
End Sub
b = b + ...
Reply
#40
(08-27-2023, 11:16 PM)bplus Wrote:
Quote:Could you possibly show me an example where we are using the absolute position value for the 2nd (x, y) and then how step would fix it?

From our very recent code rewrite for FONT.print
Code: (Select All)
Sub F0NT.print (s$, f() As F0NT, x%, y%, scale%, spacing%)
  Dim As Integer i, l, dx1, dy1, dx2, dy2, orig_x
  Dim c As String
  Dim g As Long
  l% = Len(s$)
  ' PSet (x%, y%)
  For i% = 1 To l%
    c$ = Mid$(s$, i%, 1)
    'g& =
    '_Source g&
    dx1% = x% + (i% - 1) * (COLS + spacing%) * scale%
    dy1% = y%
    'dx2% = (COLS * scale%) + dx1%  ' << STEP allows us to leave off the dx1% from which we STEP
    'dy2% = (ROWS * scale%) + dy1%  ' << STEP allows us to leave off the dx2% from which we STEP
    '_PutImage (dx1%, dy1%)-(dx2%, dy2%), F0NT.get_glyph(c$, f())
    _PutImage (dx1%, dy1%)-Step(COLS * scale% - 1, ROWS * scale% - 1), F0NT.get_glyph(c$, f())
  Next i%
End Sub
AHA! Perfect example. Let me try to explain what I understand in my own words to make sure I grok this.
  • L13 - We don't need to calc `dx2%` because with STEP that becomes relative and auto-mathic to be: x:`dx1% + COLS * scale% - 1)`?
  • L14 - We don't need to calc `dy2%` because with STEP that becomes relative and auto-mathic to be: y:`dy1% + ROWS * scale% - 1)`?
  • So! STEP uses the previous x and y in the first pair of `(x,y)` in `_PUTIMAGE` and we can simply provide width and height if we `STEP(w,h)`?
  • L16 - The reason we use `-1` in `COLS * scale% -1` and `ROWS * scale% - 1` is because in the first iteration of the loop with `i%` being 1, if we did not subtract one, it would offset them, and so the passed in desired positions would be actually offset for the first character.
  • L16 - Why are we doing a `i% - 1` in the `dx1%` on line `11`? Same reason, to prevent the offset? Since that would evaluate to `x% + (1-1)` OR `x% + 0 * (COLS + spacing%) * scale%` which means in the first pass through the loop the `x` position is also not offset in `dx1%` either, so! `STEP(-1)` thing is to make it consistent for the width and height -- but `y` is `-1` in `STEP(-1)` for height, but `dy1%` has no offset - why?

Thanks!

I think I understand `STEP`. It makes the second set of parenthesis args relative to the first set of parenthesis arg. So first set of parens = `(dx1, dy1)`. Second set is implicit dx1+ and dy1+. Right?

Can you confirm if I have the right of it for -1 for x and y on both lines 11 and 16? but curious why line 12 has no `-1` there. Ah! because in the loop we aren't offsetting `y` for each pass! the characters are adjacent on the `x` and SAME on the `y`.

NOW I get it.

ALSO something happened when I had to type this out. I realized a thing, might be obvious to others but wasn't to me.

Simplify the math and vars to understand WTF is happening.

If the code has:
`dx1% = x% + (i% - 1) * (COLS + spacing%) * scale%`

simplify pass 1:
`dx1% = x% + (1 - 1) * (COLS + spacing%) * scale%`

simplify pass 2:
`dx1% = x% + (0) * (COLS + spacing%) * scale%`

simplify pass 3:
`dx1% = x% + 0 * (COLS + spacing%) * scale%`

simplify pass 4:
If: `x% = 0 : COLS = 9 : spacing% = 2 : scale% = 3`
`dx1% = 0 + 0 * (9 + 2) * 3`

simplify pass 5:
If: `x% = 0 : COLS = 9 : spacing% = 2 : scale% = 3`
`dx1% = 0 + 0 * (11) * 3`

simplify pass 6:
If: `x% = 0 : COLS = 9 : spacing% = 2 : scale% = 3`
`dx1% = 0 + 0 * 11 * 3`

simplify pass 7:
If: `x% = 0 : COLS = 9 : spacing% = 2 : scale% = 3`
`dx1% = 0 + 0 * 11 * 3`
in loop iteration 1 `dx1% = 0`

simplify simulate `i% + 1` to assert .. so pass 8:
If: `x% = 0 : COLS = 9 : spacing% = 2 : scale% = 3`
`dx1% = 0 + (1 * 11) * 3`

simplify simulate `i% + 1` to assert .. so pass 9:
If: `x% = 0 : COLS = 9 : spacing% = 2 : scale% = 3`
`dx1% = 0 + (11) * 3`

simplify simulate `i% + 1` to assert .. so pass 10:
If: `x% = 0 : COLS = 9 : spacing% = 2 : scale% = 3`
`dx1% = 0 + 11 * 3`

simplify simulate `i% + 1` to assert .. so pass 11:
If: `x% = 0 : COLS = 9 : spacing% = 2 : scale% = 3`
`dx1% = 0 + (11 * 3)`

simplify simulate `i% + 1` to assert .. so pass 12:
If: `x% = 0 : COLS = 9 : spacing% = 2 : scale% = 3`
`dx1% = 0 + (33)`

simplify simulate `i% + 1` to assert .. so pass 13:
If: `x% = 0 : COLS = 9 : spacing% = 2 : scale% = 3`
`dx1% = 0 + 33`
in loop iteration 2 `dx1% = 33`

Idea 

I know, we can just watch those variables and debug and step through.. For some reason this didn't occur to me either.

Thanks @bplus Heart
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply




Users browsing this thread: 1 Guest(s)