Author Topic: PUTIMAGE fail - my mystake, Putimage is right.  (Read 182 times)

Petr

  • Hero Member
  • *****
  • Posts: 508
PUTIMAGE fail - my mystake, Putimage is right.
« on: September 02, 2017, 03:34:04 pm »
Hello. I'd love to hear that it's my fault, because I need to fix it quickly. So. I draw the grid with the line command. Then I put PUTIMAGE into the lower resolution screen. I just want to show the cut-out. If the SUB vstup is run separately, the grid will be rendered correctly. If I want her part to screen using PUTIMAGE, some lines are missing. What with this?

Code: [Select]
DEFLNG X, Y
DIM SHARED total AS LONG, my AS LONG
total& = _NEWIMAGE(1000, 1000, 32)
my& = _NEWIMAGE(640, 480, 32)
PosunX = 500: PosunY = 500
'Viewing start in middle
PRINT "Creating lines, wait"
vklad
mox = 320: moy = 240

SCREEN my&
PCOPY _DISPLAY, 1
DO
    DO WHILE _MOUSEINPUT
        mox = _MOUSEX: moy = _MOUSEY
        IF _MOUSEBUTTON(1) THEN Lb = 1 ELSE Lb = -1
    LOOP

    IF mox > 620 THEN PosunX = PosunX + 1
    IF mox < 20 THEN PosunX = PosunX - 1
    IF moy > 460 THEN PosunY = PosunY + 1
    IF moy < 20 THEN PosunY = PosunY - 1
    IF PosunX < 0 THEN PosunX = 0
    IF PosunX > 4000 THEN PosunX = 4000
    IF PosunY < 0 THEN PosunY = 0
    IF PosunY > 4000 THEN PosunY = 1


    PCOPY 1, _DISPLAY
    COLOR _RGB(255, 0, 0): LOCATE 1, 1: PRINT PosunX, PosunY, glx, glz
    _PUTIMAGE (0, 0)-(639, 479), total&, my&, (PosunX - 320, PosunY - 320)-(PosunX + 320, PosunY + 320)
    glx = PosunX - 500
    glz = PosunY - 500
    _DISPLAY

LOOP

SUB vklad
_DEST total&
FOR x = 1 TO 1000 STEP 20
    LINE (x, 1000)-(1000, 0), _RGB(255, 255, 255), B
NEXT x
FOR y = 1000 TO 1 STEP -20
    LINE (1000, y)-(0, 1000), _RGB(255, 255, 255), B
NEXT y


x = 0: y = 0
END SUB
« Last Edit: September 03, 2017, 12:38:22 am by Petr »
Coding is relax.

FellippeHeitor

  • QB64 Partner Site Owner
  • Hero Member
  • *
  • Posts: 1666
  • LET IT = BE
    • QB64.org
Re: PUTIMAGE doing its thing
« Reply #1 on: September 02, 2017, 06:17:22 pm »
Code: [Select]
DEFLNG X, Y
DIM SHARED total AS LONG, my AS LONG
total& = _NEWIMAGE(1000, 1000, 32)
my& = _NEWIMAGE(640, 480, 32)
PosunX = 500: PosunY = 500
'Viewing start in middle
PRINT "Creating lines, wait"
vklad
mox = 320: moy = 240

SCREEN my&
DO
    DO WHILE _MOUSEINPUT
        mox = _MOUSEX: moy = _MOUSEY
        IF _MOUSEBUTTON(1) THEN Lb = 1 ELSE Lb = -1
    LOOP

    IF mox > 620 THEN PosunX = PosunX + 1
    IF mox < 20 THEN PosunX = PosunX - 1
    IF moy > 460 THEN PosunY = PosunY + 1
    IF moy < 20 THEN PosunY = PosunY - 1
    IF PosunX < 0 THEN PosunX = 0
    IF PosunX > 4000 THEN PosunX = 4000
    IF PosunY < 0 THEN PosunY = 0
    IF PosunY > 4000 THEN PosunY = 1


    CLS
    COLOR _RGB(255, 0, 0): LOCATE 1, 1: PRINT PosunX, PosunY, glx, glz
    _PUTIMAGE (0, 0)-(639, 479), total&, my&, (PosunX - 319, PosunY - 239)-(PosunX + 319, PosunY + 239)
    glx = PosunX - 500
    glz = PosunY - 500
    _DISPLAY

LOOP

SUB vklad
    _DEST total&
    FOR x = 1 TO 1000 STEP 20
        LINE (x, 1000)-(1000, 0), _RGB(255, 255, 255), B
    NEXT x
    FOR y = 1000 TO 1 STEP -20
        LINE (1000, y)-(0, 1000), _RGB(255, 255, 255), B
    NEXT y


    x = 0: y = 0
END SUB

FellippeHeitor

  • QB64 Partner Site Owner
  • Hero Member
  • *
  • Posts: 1666
  • LET IT = BE
    • QB64.org
Re: PUTIMAGE doing its thing; ALSO: MsPaint doing its thing
« Reply #2 on: September 02, 2017, 06:26:02 pm »
You are trying to stretch an image made up of straight lines using a routine that has *no* antialiasing. Just like there's no antialiasing in MSPAINT, for example, just to name one alternative piece of software that can also stretch images. Please watch the video in the attachment.

If you stretch it while maintaining the aspect ratio, your lines will show properly.

Petr

  • Hero Member
  • *****
  • Posts: 508
Re: PUTIMAGE fail
« Reply #3 on: September 03, 2017, 12:35:10 am »
So aspect ratio. Hmmm. It did not come to my mind at all. Thank you very much! I will fix the title.
Coding is relax.