11 March 2015, 13:35 | #1 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
Scale Image with DataTypes?
Hi,
is it possible to make an Image smaller with Datatypes? If yes, how? thanks, ags |
11 March 2015, 13:40 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
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. |
11 March 2015, 13:47 | #3 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
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. 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. |
11 March 2015, 14:22 | #4 | ||
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
Yes.
Quote:
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:
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. |
||
11 March 2015, 16:05 | #5 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
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.
|
11 March 2015, 16:59 | #6 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
Ah, what if I want to scale the image while keeping aspect ratio?
|
11 March 2015, 21:58 | #7 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
|
12 March 2015, 08:06 | #8 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
XSrcFactor = SrcWidth, YSrcFactor = SrcHeight, same for Dest.
|
12 March 2015, 11:43 | #9 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
Okay, everything works fine now.
ps: even keeping aspect ratio! |
13 March 2015, 12:32 | #10 |
XoXo/Tasko Developer
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
|
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. |
13 March 2015, 13:27 | #11 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
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 |
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 |
|
|