@@ -850,13 +850,14 @@ void BB_alpha_blit_from(BlitBuffer *dst, BlitBuffer *src,
850
850
}
851
851
o_y += 1 ;
852
852
}
853
- } else if (dbb_type == TYPE_BB8A && sbb_type == TYPE_BB8A ) {
854
- Color8A * dstptr , * srcptr ;
853
+ } else if (dbb_type == TYPE_BB8 && sbb_type == TYPE_BB8A ) {
854
+ Color8A * srcptr ;
855
+ Color8 * dstptr ;
855
856
o_y = offs_y ;
856
857
for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
857
858
o_x = offs_x ;
858
859
for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
859
- BB_GET_PIXEL (dst , dbb_rotation , Color8A , d_x , d_y , & dstptr );
860
+ BB_GET_PIXEL (dst , dbb_rotation , Color8 , d_x , d_y , & dstptr );
860
861
BB_GET_PIXEL (src , sbb_rotation , Color8A , o_x , o_y , & srcptr );
861
862
alpha = srcptr -> alpha ;
862
863
ainv = 0xFF - alpha ;
@@ -865,124 +866,109 @@ void BB_alpha_blit_from(BlitBuffer *dst, BlitBuffer *src,
865
866
}
866
867
o_y += 1 ;
867
868
}
868
- } else if (dbb_type == TYPE_BBRGB16 && sbb_type == TYPE_BBRGB16 ) {
869
- ColorRGB16 * dstptr , * srcptr ;
869
+ } else if (dbb_type == TYPE_BB8 && sbb_type == TYPE_BBRGB16 ) {
870
+ ColorRGB16 * srcptr ;
871
+ Color8 * dstptr ;
870
872
o_y = offs_y ;
871
873
for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
872
874
o_x = offs_x ;
873
875
for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
874
- BB_GET_PIXEL (dst , dbb_rotation , ColorRGB16 , d_x , d_y , & dstptr );
876
+ BB_GET_PIXEL (dst , dbb_rotation , Color8 , d_x , d_y , & dstptr );
875
877
BB_GET_PIXEL (src , sbb_rotation , ColorRGB16 , o_x , o_y , & srcptr );
876
- * dstptr = * srcptr ;
878
+ dstptr -> a = ColorRGB16_To_A ( srcptr -> v ) ;
877
879
o_x += 1 ;
878
880
}
879
881
o_y += 1 ;
880
882
}
881
- } else if (dbb_type == TYPE_BBRGB24 && sbb_type == TYPE_BBRGB24 ) {
882
- ColorRGB24 * dstptr , * srcptr ;
883
+ } else if (dbb_type == TYPE_BB8 && sbb_type == TYPE_BBRGB24 ) {
884
+ ColorRGB24 * srcptr ;
885
+ Color8 * dstptr ;
883
886
o_y = offs_y ;
884
887
for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
885
888
o_x = offs_x ;
886
889
for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
887
- BB_GET_PIXEL (dst , dbb_rotation , ColorRGB24 , d_x , d_y , & dstptr );
890
+ BB_GET_PIXEL (dst , dbb_rotation , Color8 , d_x , d_y , & dstptr );
888
891
BB_GET_PIXEL (src , sbb_rotation , ColorRGB24 , o_x , o_y , & srcptr );
889
- * dstptr = * srcptr ;
892
+ dstptr -> a = RGB_To_A ( srcptr -> r , srcptr -> g , srcptr -> b ) ;
890
893
o_x += 1 ;
891
894
}
892
895
o_y += 1 ;
893
896
}
894
- } else if (dbb_type == TYPE_BBRGB32 && sbb_type == TYPE_BBRGB32 ) {
895
- ColorRGB32 * dstptr , * srcptr ;
897
+ } else if (dbb_type == TYPE_BB8 && sbb_type == TYPE_BBRGB32 ) {
898
+ ColorRGB32 * srcptr ;
899
+ Color8 * dstptr ;
900
+ uint8_t srca ;
896
901
o_y = offs_y ;
897
902
for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
898
903
o_x = offs_x ;
899
904
for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
900
- BB_GET_PIXEL (dst , dbb_rotation , ColorRGB32 , d_x , d_y , & dstptr );
905
+ BB_GET_PIXEL (dst , dbb_rotation , Color8 , d_x , d_y , & dstptr );
901
906
BB_GET_PIXEL (src , sbb_rotation , ColorRGB32 , o_x , o_y , & srcptr );
902
907
alpha = srcptr -> alpha ;
903
908
ainv = 0xFF - alpha ;
904
- dstptr -> r = DIV_255 (dstptr -> r * ainv + srcptr -> r * alpha );
905
- dstptr -> g = DIV_255 (dstptr -> g * ainv + srcptr -> g * alpha );
906
- dstptr -> b = DIV_255 (dstptr -> b * ainv + srcptr -> b * alpha );
909
+ srca = RGB_To_A (srcptr -> r , srcptr -> g , srcptr -> b );
910
+ dstptr -> a = DIV_255 (dstptr -> a * ainv + srca * alpha );
907
911
o_x += 1 ;
908
912
}
909
913
o_y += 1 ;
910
914
}
911
- } else if (dbb_type == TYPE_BBRGB32 && sbb_type == TYPE_BBRGB24 ) {
912
- ColorRGB32 * dstptr ;
913
- ColorRGB24 * srcptr ;
915
+ } else if (dbb_type == TYPE_BB8A && sbb_type == TYPE_BB8A ) {
916
+ Color8A * dstptr , * srcptr ;
914
917
o_y = offs_y ;
915
918
for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
916
919
o_x = offs_x ;
917
920
for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
918
- BB_GET_PIXEL (dst , dbb_rotation , ColorRGB32 , d_x , d_y , & dstptr );
919
- BB_GET_PIXEL (src , sbb_rotation , ColorRGB24 , o_x , o_y , & srcptr );
920
- dstptr -> r = srcptr -> r ;
921
- dstptr -> g = srcptr -> g ;
922
- dstptr -> b = srcptr -> b ;
923
- dstptr -> alpha = 0xFF ;
921
+ BB_GET_PIXEL (dst , dbb_rotation , Color8A , d_x , d_y , & dstptr );
922
+ BB_GET_PIXEL (src , sbb_rotation , Color8A , o_x , o_y , & srcptr );
923
+ alpha = srcptr -> alpha ;
924
+ ainv = 0xFF - alpha ;
925
+ dstptr -> a = DIV_255 (dstptr -> a * ainv + srcptr -> a * alpha );
924
926
o_x += 1 ;
925
927
}
926
928
o_y += 1 ;
927
929
}
928
- } else if (dbb_type == TYPE_BBRGB32 && sbb_type == TYPE_BB8 ) {
929
- ColorRGB32 * dstptr ;
930
+ } else if (dbb_type == TYPE_BBRGB16 && sbb_type == TYPE_BB8 ) {
930
931
Color8 * srcptr ;
932
+ ColorRGB16 * dstptr ;
931
933
o_y = offs_y ;
932
934
for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
933
935
o_x = offs_x ;
934
936
for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
935
- BB_GET_PIXEL (dst , dbb_rotation , ColorRGB32 , d_x , d_y , & dstptr );
937
+ BB_GET_PIXEL (dst , dbb_rotation , ColorRGB16 , d_x , d_y , & dstptr );
936
938
BB_GET_PIXEL (src , sbb_rotation , Color8 , o_x , o_y , & srcptr );
937
- dstptr -> r = srcptr -> a ;
938
- dstptr -> g = srcptr -> a ;
939
- dstptr -> b = srcptr -> a ;
940
- dstptr -> alpha = 0xFF ;
941
- o_x += 1 ;
942
- }
943
- o_y += 1 ;
944
- }
945
- } else if (dbb_type == TYPE_BBRGB32 && sbb_type == TYPE_BB8A ) {
946
- ColorRGB32 * dstptr ;
947
- Color8A * srcptr ;
948
- o_y = offs_y ;
949
- for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
950
- o_x = offs_x ;
951
- for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
952
- BB_GET_PIXEL (dst , dbb_rotation , ColorRGB32 , d_x , d_y , & dstptr );
953
- BB_GET_PIXEL (src , sbb_rotation , Color8A , o_x , o_y , & srcptr );
954
- dstptr -> r = srcptr -> a ;
955
- dstptr -> g = srcptr -> a ;
956
- dstptr -> b = srcptr -> a ;
957
- dstptr -> alpha = srcptr -> alpha ; // if bad result, try: 0xFF - srcptr->alpha
939
+ dstptr -> v = RGB_To_RGB16 (srcptr -> a , srcptr -> a , srcptr -> a );
958
940
o_x += 1 ;
959
941
}
960
942
o_y += 1 ;
961
943
}
962
944
} else if (dbb_type == TYPE_BBRGB16 && sbb_type == TYPE_BB8A ) {
963
945
Color8A * srcptr ;
964
946
ColorRGB16 * dstptr ;
947
+ uint8_t dsta , bdsta ;
965
948
o_y = offs_y ;
966
949
for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
967
950
o_x = offs_x ;
968
951
for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
969
952
BB_GET_PIXEL (dst , dbb_rotation , ColorRGB16 , d_x , d_y , & dstptr );
970
953
BB_GET_PIXEL (src , sbb_rotation , Color8A , o_x , o_y , & srcptr );
971
- dstptr -> v = RGB_To_RGB16 (srcptr -> a , srcptr -> a , srcptr -> a );
954
+ alpha = srcptr -> alpha ;
955
+ ainv = 0xFF - alpha ;
956
+ dsta = ColorRGB16_To_A (dstptr -> v );
957
+ bdsta = DIV_255 (dsta * ainv + srcptr -> a * alpha );
958
+ dstptr -> v = RGB_To_RGB16 (bdsta , bdsta , bdsta );
972
959
o_x += 1 ;
973
960
}
974
961
o_y += 1 ;
975
962
}
976
- } else if (dbb_type == TYPE_BBRGB16 && sbb_type == TYPE_BB8 ) {
977
- Color8 * srcptr ;
978
- ColorRGB16 * dstptr ;
963
+ } else if (dbb_type == TYPE_BBRGB16 && sbb_type == TYPE_BBRGB16 ) {
964
+ ColorRGB16 * dstptr , * srcptr ;
979
965
o_y = offs_y ;
980
966
for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
981
967
o_x = offs_x ;
982
968
for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
983
969
BB_GET_PIXEL (dst , dbb_rotation , ColorRGB16 , d_x , d_y , & dstptr );
984
- BB_GET_PIXEL (src , sbb_rotation , Color8 , o_x , o_y , & srcptr );
985
- dstptr -> v = RGB_To_RGB16 ( srcptr -> a , srcptr -> a , srcptr -> a ) ;
970
+ BB_GET_PIXEL (src , sbb_rotation , ColorRGB16 , o_x , o_y , & srcptr );
971
+ * dstptr = * srcptr ;
986
972
o_x += 1 ;
987
973
}
988
974
o_y += 1 ;
@@ -1021,6 +1007,93 @@ void BB_alpha_blit_from(BlitBuffer *dst, BlitBuffer *src,
1021
1007
}
1022
1008
o_y += 1 ;
1023
1009
}
1010
+ } else if (dbb_type == TYPE_BBRGB24 && sbb_type == TYPE_BBRGB24 ) {
1011
+ ColorRGB24 * dstptr , * srcptr ;
1012
+ o_y = offs_y ;
1013
+ for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
1014
+ o_x = offs_x ;
1015
+ for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
1016
+ BB_GET_PIXEL (dst , dbb_rotation , ColorRGB24 , d_x , d_y , & dstptr );
1017
+ BB_GET_PIXEL (src , sbb_rotation , ColorRGB24 , o_x , o_y , & srcptr );
1018
+ * dstptr = * srcptr ;
1019
+ o_x += 1 ;
1020
+ }
1021
+ o_y += 1 ;
1022
+ }
1023
+ } else if (dbb_type == TYPE_BBRGB32 && sbb_type == TYPE_BBRGB32 ) {
1024
+ ColorRGB32 * dstptr , * srcptr ;
1025
+ o_y = offs_y ;
1026
+ for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
1027
+ o_x = offs_x ;
1028
+ for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
1029
+ BB_GET_PIXEL (dst , dbb_rotation , ColorRGB32 , d_x , d_y , & dstptr );
1030
+ BB_GET_PIXEL (src , sbb_rotation , ColorRGB32 , o_x , o_y , & srcptr );
1031
+ alpha = srcptr -> alpha ;
1032
+ ainv = 0xFF - alpha ;
1033
+ dstptr -> r = DIV_255 (dstptr -> r * ainv + srcptr -> r * alpha );
1034
+ dstptr -> g = DIV_255 (dstptr -> g * ainv + srcptr -> g * alpha );
1035
+ dstptr -> b = DIV_255 (dstptr -> b * ainv + srcptr -> b * alpha );
1036
+ //dstptr->alpha = dstptr->alpha;
1037
+ o_x += 1 ;
1038
+ }
1039
+ o_y += 1 ;
1040
+ }
1041
+ } else if (dbb_type == TYPE_BBRGB32 && sbb_type == TYPE_BBRGB24 ) {
1042
+ ColorRGB32 * dstptr ;
1043
+ ColorRGB24 * srcptr ;
1044
+ o_y = offs_y ;
1045
+ for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
1046
+ o_x = offs_x ;
1047
+ for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
1048
+ BB_GET_PIXEL (dst , dbb_rotation , ColorRGB32 , d_x , d_y , & dstptr );
1049
+ BB_GET_PIXEL (src , sbb_rotation , ColorRGB24 , o_x , o_y , & srcptr );
1050
+ dstptr -> r = srcptr -> r ;
1051
+ dstptr -> g = srcptr -> g ;
1052
+ dstptr -> b = srcptr -> b ;
1053
+ //dstptr->alpha = dstptr->alpha;
1054
+ o_x += 1 ;
1055
+ }
1056
+ o_y += 1 ;
1057
+ }
1058
+ } else if (dbb_type == TYPE_BBRGB32 && sbb_type == TYPE_BB8 ) {
1059
+ ColorRGB32 * dstptr ;
1060
+ Color8 * srcptr ;
1061
+ o_y = offs_y ;
1062
+ for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
1063
+ o_x = offs_x ;
1064
+ for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
1065
+ BB_GET_PIXEL (dst , dbb_rotation , ColorRGB32 , d_x , d_y , & dstptr );
1066
+ BB_GET_PIXEL (src , sbb_rotation , Color8 , o_x , o_y , & srcptr );
1067
+ dstptr -> r = srcptr -> a ;
1068
+ dstptr -> g = srcptr -> a ;
1069
+ dstptr -> b = srcptr -> a ;
1070
+ //dstptr->alpha = dstptr->alpha;
1071
+ o_x += 1 ;
1072
+ }
1073
+ o_y += 1 ;
1074
+ }
1075
+ } else if (dbb_type == TYPE_BBRGB32 && sbb_type == TYPE_BB8A ) {
1076
+ ColorRGB32 * dstptr ;
1077
+ Color8A * srcptr ;
1078
+ uint8_t dsta , bdsta ;
1079
+ o_y = offs_y ;
1080
+ for (d_y = dest_y ; d_y < dest_y + h ; d_y ++ ) {
1081
+ o_x = offs_x ;
1082
+ for (d_x = dest_x ; d_x < dest_x + w ; d_x ++ ) {
1083
+ BB_GET_PIXEL (dst , dbb_rotation , ColorRGB32 , d_x , d_y , & dstptr );
1084
+ BB_GET_PIXEL (src , sbb_rotation , Color8A , o_x , o_y , & srcptr );
1085
+ alpha = srcptr -> alpha ;
1086
+ ainv = 0xFF - alpha ;
1087
+ dsta = RGB_To_A (dstptr -> r , dstptr -> g , dstptr -> b );
1088
+ bdsta = DIV_255 (dsta * ainv + srcptr -> a * alpha );
1089
+ dstptr -> r = bdsta ;
1090
+ dstptr -> g = bdsta ;
1091
+ dstptr -> b = bdsta ;
1092
+ //dstptr->alpha = dstptr->alpha;
1093
+ o_x += 1 ;
1094
+ }
1095
+ o_y += 1 ;
1096
+ }
1024
1097
} else {
1025
1098
fprintf (stderr , "incompatible bb (dst: %d, src: %d) in file %s, line %d!\r\n" ,
1026
1099
dbb_type , sbb_type , __FILE__ , __LINE__ ); exit (1 );
0 commit comments