English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 27 August 2014, 15:53   #61
Vot
Registered User

 
Join Date: Aug 2012
Location: Australia
Posts: 646
Quote:
Originally Posted by ags View Post
well, we found a way to take the merged background color, if it is black, into account and output nevertheless a correct image. I used both the dtimage.library and the pngalpha.library and applied the alpha info onto the rgb info. Of course this is an overhead. Thus i am now working with peterk on a custom png decoder for my selfmade gui engine. I am also thinking about implementing it as a new library with open source. Noone should have problems with this task anymore.
👏👍
Vot is offline  
AdSense AdSense  
Old 27 August 2014, 15:56   #62
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 42
Posts: 450
I am sorry but my Browser does not show the chars of your reply correctly. The only thing I see are two Placeholders for unicode-characters, one reading "01f 44f" and the other "01f 44d".
AGS is offline  
Old 27 August 2014, 20:12   #63
Lonewolf10
AMOS Extensions Developer
Lonewolf10's Avatar
 
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 38
Posts: 1,917
Quote:
Originally Posted by AGS View Post
I am sorry but my Browser does not show the chars of your reply correctly. The only thing I see are two Placeholders for unicode-characters, one reading "01f 44f" and the other "01f 44d".
I have the same issue. Are you using Firefox (3.6.22) like me?
Lonewolf10 is offline  
Old 27 August 2014, 20:16   #64
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 42
Posts: 450
My OS is Ubuntu Linux and my Firefox is versioned 29.0.
AGS is offline  
Old 27 August 2014, 21:06   #65
Franchute13
Registered User
Franchute13's Avatar
 
Join Date: Feb 2013
Location: Argentina
Posts: 227
Work fine here. Windows 8 - Firefox 28.0
http://www.subeimagenes.com/img/sin-titulo-1071976.jpg
Franchute13 is offline  
Old 27 August 2014, 21:12   #66
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 42
Posts: 450
Probably that are rather new special chars only available in Windows. Thanks for the Translation.
AGS is offline  
Old 27 August 2014, 21:55   #67
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
Quote:
Originally Posted by AGS View Post
But d3 is my 255 value.
it doesn't matter, we're not using it anymore

Quote:
Originally Posted by AGS View Post
I mean, I again cannot see a difference wether I use spl, smi or none of the two. How do I know, it is correct?
well as i say the maximum possible difference is only 1, you would need a very good monitor to see the difference.
Mrs Beanbag is offline  
Old 27 August 2014, 22:15   #68
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 42
Posts: 450
PeterK figured out that the spl and following lsr #8 eliminate each other. spl sets the low byte to either 0 or $ff and the lsr vanishes these 8 bits. So it really makes no difference.
AGS is offline  
Old 27 August 2014, 22:30   #69
Leffmann

 
Join Date: Jul 2008
Location: Sweden
Posts: 2,025
Quote:
Originally Posted by Mrs Beanbag View Post
@Leffman you can replace x/256 by (x+128) >> 8 for correct rounding
Almost With integer arithmetic you always round towards 0, so you would have to add 255, and only when you have a negative operand, but it can be done branch-less with a couple of shifts and an add.
Leffmann is offline  
Old 27 August 2014, 22:38   #70
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
Quote:
Originally Posted by Leffmann View Post
Almost With integer arithmetic you always round towards 0, so you would have to add 255, and only when you have a negative operand, but it can be done branch-less with a couple of shifts and an add.
but that would make 1/256 = 1, i don't know why you would want that. Rounding to the nearest int, (128..256)/256 = 1 but (0..127)/256 = 0.

If you always want to round down, no adding is necessary, the problem there is it is not symmetric around zero, you might prefer to round negative numbers up instead.
Mrs Beanbag is offline  
Old 27 August 2014, 22:43   #71
Leffmann

 
Join Date: Jul 2008
Location: Sweden
Posts: 2,025
With two's complement integer arithmetic we always want to round towards 0, so we only add 255 if we have a negative operand, and both -1/256 and 1/256 will become 0.
Leffmann is offline  
Old 28 August 2014, 00:11   #72
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
well you might always want to round towards 0, personally i find rounding to the nearest int quite pleasing
Mrs Beanbag is offline  
Old 28 August 2014, 01:31   #73
Vot
Registered User

 
Join Date: Aug 2012
Location: Australia
Posts: 646
Quote:
Originally Posted by AGS View Post
I am sorry but my Browser does not show the chars of your reply correctly. The only thing I see are two Placeholders for unicode-characters, one reading "01f 44f" and the other "01f 44d".
Sorry they are emjoi charset characters..
Vot is offline  
Old 29 August 2014, 21:13   #74
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 42
Posts: 450
Ok, here is the pngflux.library to load and draw PNG images w/ alphachannel support:

http://eab.abime.net/showthread.php?t=74927
AGS is offline  
Old 02 September 2014, 11:33   #75
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 42
Posts: 450
Question

@Mrs Beanbag

Is this good? We multiply alpha with 257 and then divide by 65536 in a swap.

Code:
calc_pixels    ; apply ARGB data onto RGB data

        moveq    #0,d0            ; image
        moveq    #0,d1            ; screen
        moveq    #0,d2            ; alpha
        move.w    #255,d3

.loop        move.b    (a0)+,d2        ; get alpha value
        beq    .skip            ; full transparency?

        cmp.b    d3,d2            ; full opaqueness?
        beq    .copy

        move.b    d2,d0
        lsl.w    #8,d2
        add.b    d0,d2

        moveq    #0,d0

        move.b    (a0)+,d0
        move.b    (a1),d1
        sub.l    d1,d0
        muls.l    d2,d0
        swap    d0
        add.w    d1,d0
        move.b    d0,(a1)+

        moveq    #0,d0

        move.b    (a0)+,d0
        move.b    (a1),d1
        sub.l    d1,d0
        muls.l    d2,d0
        swap    d0
        add.w    d1,d0
        move.b    d0,(a1)+

        moveq    #0,d0

        move.b    (a0)+,d0
        move.b    (a1),d1
        sub.l    d1,d0
        muls.l    d2,d0
        swap    d0
        add.w    d1,d0
        move.b    d0,(a1)+

        dbf    d7,.loop
        rts

.skip        addq.l    #3,a0
        addq.l    #3,a1
        dbf    d7,.loop
        rts

.copy        move.b    (a0)+,(a1)+
        move.b    (a0)+,(a1)+
        move.b    (a0)+,(a1)+
        dbf    d7,.loop
        rts
AGS is offline  
Old 02 September 2014, 12:16   #76
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
actually it is better to multiply by 258 since both the multiplicands range from 0 to 255, and 256*65535/(255*255) ~= 258. This is like multiplying both numbers by 257. (257*257)/256 ~= 258.
Mrs Beanbag is offline  
Old 02 September 2014, 12:24   #77
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 42
Posts: 450
The alpha value does not range from 0 to 255. 255 is handled separately as "copy". Thus it ranges up tp 254. I don't know, if this makes a difference?

Last edited by AGS; 02 September 2014 at 12:39.
AGS is offline  
Old 02 September 2014, 14:05   #78
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
Quote:
Originally Posted by AGS View Post
The alpha value does not range from 0 to 255. 255 is handled separately as "copy". Thus it ranges up tp 254. I don't know, if this makes a difference?
no it won't make a difference, the "range" of alpha is still 0..255 but 255 is handled as a special case. The rest of the range 0..254 still needs to be correct for a range of 0..255.

Also of course alpha=0 is a special case as well.
Mrs Beanbag is offline  
Old 02 September 2014, 14:37   #79
AGS
XoXo/Tasko Developer
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 42
Posts: 450
Why can't I again see a difference between multiplying with 257 and 258?
AGS is offline  
Old 02 September 2014, 15:04   #80
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
Quote:
Originally Posted by AGS View Post
Why can't I again see a difference between multiplying with 257 and 258?
because the difference is very small! when the maximum difference is 1 part in 255 you would need to look very carefully on a really good monitor, and most of the pixels are probably exactly the same between versions.
Mrs Beanbag is offline  
AdSense AdSense  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tool to convert asm to gnu asm (gas) Asman Coders. Asm / Hardware 6 12 October 2013 13:45
TCP/IP stack: Most optimized//small? Akira support.Apps 17 14 June 2008 01:42
Optimized Protracker playroutine? Photon Coders. General 10 11 June 2005 01:54

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 01:42.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Page generated in 0.20632 seconds with 13 queries