English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 11 March 2015, 13:35   #1
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
Question Scale Image with DataTypes?

Hi,

is it possible to make an Image smaller with Datatypes? If yes, how?

thanks,
ags
AGS is offline  
Old 11 March 2015, 13:40   #2
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,375
Only in OS 3.9 and above there is PDTM_SCALE.

But if you read the bitmap from the datatype anyway, you can as well use BitMapScale in graphics.library.
thomas is offline  
Old 11 March 2015, 13:47   #3
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
Question

Great idea, thank you. Now, what are these for:

Code:
	    bsa_XSrcFactor:bsa_XDestFactor - equivalent to the ratio
	        srcWidth:destWidth, but not necessarily the same
	        numbers.  Each must be in the range 1..16383.
	    bsa_YSrcFactor:bsa_YDestFactor - equivalent to the ratio
	        srcHeight:destHeight, but not necessarily the same
	        numbers.  Each must be in the range 1..16383.
Do I need them? I cannot see why.


PS: And is it possible to get the filetype with datatypes, i.e. if it's music or graphics?

Last edited by AGS; 11 March 2015 at 13:54.
AGS is offline  
Old 11 March 2015, 14:22   #4
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,375
Quote:
Originally Posted by AGS View Post
Do I need them?
Yes.

Quote:
I cannot see why.
Because the documentation says so?

Your bitmaps might be bigger than the area you want to scale, therefore the factors determine by which factor scaling is done. For your special case X*Factor = *Width and Y*Factor = *Height.

Quote:
PS: And is it possible to get the filetype with datatypes, i.e. if it's music or graphics?
If you want to restrict loading to a certain type, you can set DTA_GroupID in NewDTObject.
If you want to load every type of file and then determine what it is, you can GetDTAttrs(DTA_DataType).
If you want to find out what type a file is without loading it, ObtainDataType is the function to use.
thomas is offline  
Old 11 March 2015, 16:05   #5
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
I don't get it. I think I just do it the way the docu says. But if anyone could describe me this, it would also be good.
AGS is offline  
Old 11 March 2015, 16:59   #6
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
Ah, what if I want to scale the image while keeping aspect ratio?
AGS is offline  
Old 11 March 2015, 21:58   #7
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
Quote:
Originally Posted by thomas View Post
Yes.
For your special case X*Factor = *Width and Y*Factor = *Height.
I don't understand what the asterisks in front of Width and Height mean. Please could you explain or write the formulas more detailed?
AGS is offline  
Old 12 March 2015, 08:06   #8
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,375
XSrcFactor = SrcWidth, YSrcFactor = SrcHeight, same for Dest.
thomas is offline  
Old 12 March 2015, 11:43   #9
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
Okay, everything works fine now.

ps: even keeping aspect ratio!
AGS is offline  
Old 13 March 2015, 12:32   #10
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 46
Posts: 450
Question

I noticed that sometimes (seldom) the scaled image is slightly bigger than the available space and/or a one pixel border of some other color is to the right. can you see why? this is my aspect-ratio calculation:

Code:
.scale		; aspect ratio

		;// Calculate new size
		;if((containerw_d2 - picwidth_d4) > (containerh_d3 - picheight_d5)) {
			// use height
			;s = containerh_d3 / picheight_d5;
			;nw = round(picwidth_d4 * s);
			;nh = containerh_d3;
		;}
		;else { // Use width
			;s = containerw_d2 / picwidth_d4;
			;nw = containerw_d2;
			;nh = round(picheight_d5 * s);
		;}

		sub.w	d4,d2
		sub.w	d5,d3
		cmp.w	d2,d3
		bgt	.use_width

		movem.w	oxO_width(a3),d2/d3
		move.w	d3,d2
		mulu.w	d4,d2

		move.w	d5,d6
		lsr.w	#1,d6
		add.w	d6,d2

		divu.w	d5,d2
	
		bra	.center_scaled

.use_width	movem.w	oxO_width(a3),d2/d3
		move.w	d2,d3
		mulu.w	d5,d3
		
		move.w	d4,d6
		lsr.w	#1,d6
		add.w	d6,d3

		divu.w	d4,d3

.center_scaled	; new width and height now in d2 and d3

Last edited by AGS; 13 March 2015 at 12:42.
AGS is offline  
Old 13 March 2015, 13:27   #11
thomas
Registered User
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 6,375
I don't understand your code. This is how I would do it:

Code:
new_w = max_w
new_h = old_h * max_w / old_w
if new_h > max_h then
	new_h = max_h
	new_w = old_w * max_h / old_h
endif
thomas is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Any way to use auto-scale but keep pixel ratio? WDeranged support.WinUAE 12 09 October 2015 20:39
Datatypes.library 44.48 anyone? Amicol request.Other 3 26 August 2014 23:02
Image Scale x2 BippyM project.EAB 0 26 June 2013 23:36
Scale fullscreen mode independently? Neutrino support.WinUAE 1 12 March 2009 17:08
AFA OS and datatypes Rod_cl support.Apps 0 16 September 2006 01:39

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 15:58.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.13379 seconds with 15 queries