It is currently Wed Sep 30, 2020 10:29 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: [Done] ResizeImage fails
PostPosted: Fri Jul 17, 2020 10:42 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1007
(Edit: This is a confirmed bug per Demivec's reply; can a mod move this to "Bug Reports" please?)

Here's some dead-simple code that doesn't work. Just trying to copy the image from the clipboard, and resize it to 32 x 32 pixels; but the size doesn't change. My fault?

Code:
i=GetClipboardImage(#PB_Any)
Debug Str(ImageWidth(i))+"x"+Str(ImageHeight(i)) ; Returns 1476x1635
a=ResizeImage(i,32,32)
Debug Str(a) ; Returns 0 (fail to resize - why?)
Debug Str(ImageWidth(i))+"x"+Str(ImageHeight(i)) ; Returns 1476x1635 (no change)

Here's the source image to copy to the clipboard before running the code -> https://i.imgur.com/xtXqluE.jpg

Using UseJPEGImageDecoder() before it doesn't help, and it doesn't work without #PB_Any either.

Code:
i=GetClipboardImage(0)
Debug Str(ImageWidth(0))+"x"+Str(ImageHeight(0)) ; 1476x1635
a=ResizeImage(0,32,32)
Debug Str(a) ; 0 (fail to resize - why?)
Debug Str(ImageWidth(0))+"x"+Str(ImageHeight(0)) ; 1476x1635


Last edited by BarryG on Sat Jul 18, 2020 1:42 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage fails
PostPosted: Fri Jul 17, 2020 10:58 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3741
Location: Utah, USA
I suspect the image format from the clipboard has some issues that prevent the resizing. Copying the image first and then resizing it works.

Code:
i=GetClipboardImage(#PB_Any)
Debug Str(ImageWidth(i))+"x"+Str(ImageHeight(i)) ; Returns 1476x1635
i2 = CopyImage(i, #PB_Any) ;make copy
a=ResizeImage(i2,32,32)
Debug Str(a) ; Returns 0 (fail to resize - why?)
Debug Str(ImageWidth(i2))+"x"+Str(ImageHeight(i2)) ; Returns 32x32

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage fails
PostPosted: Fri Jul 17, 2020 11:02 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1007
Thanks Demivec; that works. Shame we need to copy the image first (especially for extremely large images!).

Here's how I ended up coding it to make it seamless:

Code:
c=GetClipboardImage(#PB_Any)
i=CopyImage(c,#PB_Any)
FreeImage(c)
Debug Str(ImageWidth(i))+"x"+Str(ImageHeight(i)) ; Returns 1476x1635
a=ResizeImage(i,32,32)
Debug Str(a) ; Returns 251988331
Debug Str(ImageWidth(i))+"x"+Str(ImageHeight(i)) ; Returns 32x32


Last edited by BarryG on Sat Jul 18, 2020 1:41 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage fails
PostPosted: Fri Jul 17, 2020 11:27 am 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4934
Location: Germany
@BarryG

Your last solution results in memory waste/leak.
Because you can not free the image which came from the clipboard.
You have no imagenumber :wink:
So it stays in memory until you close the program.


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage fails
PostPosted: Fri Jul 17, 2020 11:36 am 
Offline
Addict
Addict

Joined: Thu Apr 18, 2019 8:17 am
Posts: 1007
infratec wrote:
Your last solution results in memory waste/leak.

Post edited. Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: ResizeImage fails
PostPosted: Mon Sep 14, 2020 10:46 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14090
Location: France
Fixed.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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