It is currently Wed Sep 30, 2020 11:42 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: [Done] Fix ResizeImage as parameter 0 cause problems
PostPosted: Tue Jul 28, 2020 7:37 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
Hi, try this,
Win 10 x64 PB 5.72
Reduces an image to zero,
there are massive problems.
Exes are no longer terminated and continue to run as multiple instances in the background until the computer starts to steam.
Just give it a try, there are already problems when closing the window.

Best Regards Saki

Code:
window_ID = OpenWindow(#PB_Any , 0 , 0 , 1000 , 500 , "")

imageID = CreateImage(#PB_Any , 100 , 100)

ResizeImage(imageID , 0 , 0)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow


Code:
; Workaround
Procedure ResizeImage_(ID , width , height , mode = #PB_Image_Smooth)
  If width < 1 Or height < 1
   Procedurereturn 0
  EndIf
  ProcedureReturn ResizeImage(ID , width , height , mode)
EndProcedure
Macro ResizeImage(ID , width , height , mode = #PB_Image_Smooth)
  ResizeImage_(image_ID , width , height , mode)
EndMacro

_________________
地球上の平和


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 12:37 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Dec 23, 2009 3:26 pm
Posts: 212
Hello 崎,

Win 10 x64 PB x86 5.72,
no problem.
Code:
; Workaround
Procedure ResizeImage_(ID , width , height , mode = #PB_Image_Smooth)
  If width < 1 Or height < 1
   ProcedureReturn 0
  EndIf
  ProcedureReturn ResizeImage(ID , width , height , mode)
EndProcedure
Macro ResizeImage(ID , width , height , mode = #PB_Image_Smooth)
  ResizeImage_(image_ID , width , height , mode)
EndMacro


window_ID = OpenWindow(#PB_Any , 0 , 0 , 1000 , 500 , "")

imageID = CreateImage(#PB_Any , 100 , 100)

ResizeImage(imageID , 0 , 0)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

_________________
poor English...

PureBasic & Delphi & VBA


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 12:41 pm 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1007
leonhardt wrote:
Win 10 x64 PB x86 5.72,
no problem.

That's what I have, and it freezes for me like Saki reports. So for me: bug is confirmed. ResizeImage shouldn't allow 0 for width and height anyway, and should raise an error (like it does for CreateImage).


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 1:11 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
@leonhardt
You must not execute the code with the workaround.
That's to fix the problem :wink:

_________________
地球上の平和


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 1:13 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Dec 23, 2009 3:26 pm
Posts: 212
I don't know whether it is a Windows issue, some code get AV for me while others don't, for example:
Code:
Procedure pa()
  fname.s=OpenFileRequester("open","","any|*.*",0)
  If fname=""
    ProcedureReturn
  EndIf
  tmp.s="SaveAs('"+SaveFileRequester("save as",
  "file","any|*.*",0)
EndProcedure

OpenWindow(0,0,0,100,100,"",#PB_Window_ScreenCentered)
CreateMenu(1,WindowID(0))
MenuTitle("dd")
MenuItem(3,"ff")
BindEvent(#PB_Event_Menu,@pa(),0,3)
Repeat
 
Until WaitWindowEvent()=#PB_Event_CloseWindow

if I choose some file and then save it somewhere or not, the AV comes out.

_________________
poor English...

PureBasic & Delphi & VBA


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 1:24 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
@leonhardt
Believing something doesn't help here, it's a pretty bad bug.

If you run it without the workaround, closing the window will not terminate it.

It's not uncommon to get to zero when zooming with the image size.
If such a program is called cyclically and the OS is not restarted sometimes, your computer will freeze and crash.
It's gonna get hot, need lots of power, all the cores will be occupied.

_________________
地球上の平和


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 1:32 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Dec 23, 2009 3:26 pm
Posts: 212
oh sorry , and as you said, the exe is frosen, so it should be a bug.

_________________
poor English...

PureBasic & Delphi & VBA


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 1:37 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
In your code above you have an error, so the window cannot be closed.

You must use it so :
Code:
#PB_Window_SystemMenu | #PB_Window_ScreenCentered


Best Regards Saki

_________________
地球上の平和


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 1:49 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3741
Location: Utah, USA
It's not a bug, the documenation for ResizeImage() says you must use a height and width both greater than zero.

Help File: Resize Image

That means you should always use the workaround or similar code if you aren't able to guarantee that the parameters will be within specs to begin with according to your needs.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 2:01 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
Hi demivec

<Return value
Returns nonzero if the operation succeeded and zero if it failed>.

It's a bad thing when it happens and you don't know the reason.
I think it's PB's job to prevent that from happening.
Zero is reported back, which makes no sense if the machine crashes anyway.

The fact that images cannot be reduced to zero is self-evident.
But this results in hidden misconduct, which is not good.

_________________
地球上の平和


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 2:18 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3741
Location: Utah, USA
Saki wrote:
<Return value
Returns nonzero if the operation succeeded and zero if it failed>.

It's a bad thing when it happens and you don't know the reason.
I think it's PB's job to prevent that from happening.
Zero is reported back, which makes no sense if the machine crashes anyway.


What makes no sense is why you would pass a parameter with a prohibited value to a function and that you can't conclude it is your fault that it doesn't succeed.

It's a bad thing if you don't follow the documentation for the function and you know that you should.

The function can fail for other reasons due to resources. Just because you can guarantee it will fail by not passing allowed values doesn't mean there is a bug. It indicates bad programming. PureBasic cannot prevent you from being foolish. At some point the programmer has to take responsibility for their own mistakes.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 2:26 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
A command that can so insidiously paralyze a PC by entering zero is never right.

The manual only says that it does not work with zero, but not that this causes a serious error.

It is actually the simplest thing to expect that a resizing that cannot be executed will simply not do it.
For this, zero is reported back.
Reporting zero and covertly putting the system into a defective state is never OK.

So you are right : "It indicates bad programming."

_________________
地球上の平和


Last edited by Saki on Sat Aug 01, 2020 7:20 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Auf Null gesetzt, gibt es massive Prob
PostPosted: Wed Jul 29, 2020 2:58 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3741
Location: Utah, USA
Saki wrote:
There manual only says that it does not work with zero, but not that this causes a serious error."

The manual says that both width and height must be greater than zero.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Set to zero, there are massive problem
PostPosted: Wed Jul 29, 2020 3:01 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Apr 05, 2020 11:28 am
Posts: 234
Location: Pandora
It's not a bug, it's a feature, say the programmer 8).

However, it should then be noted in the manual that the system will go into
an uncontrolled state unnoticed when the parameters become zero.

It should be obvious, that this problem was only forgotten to intercept; with other commands this is also done !

I also don't see any error in making the values null, that's why null is reported back when it fails.

Surely you can't be serious, to declare a function, which damages a system by an out of range parameter as OK ?
No offense, but I almost fall off my chair.

This is so never OK

_________________
地球上の平和


Last edited by Saki on Sat Aug 01, 2020 7:21 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage Bug - Auf Null gesetzt, gibt es massive Prob
PostPosted: Wed Jul 29, 2020 5:42 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3741
Location: Utah, USA
Saki wrote:
Surely you can't be serious, to declare a function, which damages a system by an out of range parameter as OK ?
No offense, but I almost fall off my chair.

This is so never OK

You ever heard of PokeI() or CallFunctionFast()? They can both cause mayhem.

I have shared the information that I thought was relevant to the issue. I don't have anything else to add.

Cheers.

_________________
Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye