Subversion Repositories Kolibri OS

Rev

Rev 2733 | Rev 7279 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2733 Rev 6733
Line 15... Line 15...
15
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev.  ;;
15
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev.  ;;
16
;; If not, see .                                                    ;;
16
;; If not, see .                                                    ;;
17
;;                                                                                                ;;
17
;;                                                                                                ;;
18
;;================================================================================================;;
18
;;================================================================================================;;
Line -... Line 19...
-
 
19
 
-
 
20
include 'libpng/png.asm'
19
 
21
 
20
;;================================================================================================;;
22
;;================================================================================================;;
21
;;proc img.is.png _data, _length ;////////////////////////////////////////////////////////////////;;
23
;;proc img.is.png _data, _length ;////////////////////////////////////////////////////////////////;;
22
img.is.png:
24
img.is.png:
23
;;------------------------------------------------------------------------------------------------;;
25
;;------------------------------------------------------------------------------------------------;;
Line 1074... Line 1076...
1074
	loop	@b
1076
	loop	@b
1075
	pop	edx edi
1077
	pop	edx edi
1076
	ret
1078
	ret
1077
;endp
1079
;endp
Line -... Line 1080...
-
 
1080
 
-
 
1081
 
-
 
1082
 
-
 
1083
;;================================================================================================;;
-
 
1084
align 4
-
 
1085
proc img.encode.png uses ebx edx, _img:dword, _common:dword, _specific:dword
-
 
1086
;;------------------------------------------------------------------------------------------------;;
-
 
1087
;? Encode image into raw data in png format                                                       ;;
-
 
1088
;;------------------------------------------------------------------------------------------------;;
-
 
1089
;> [_img]      = pointer to image                                                                 ;;
-
 
1090
;> [_common]   = format independent options                                                       ;;
-
 
1091
;> [_specific] = 0 / pointer to the structure of format specific options                          ;;
-
 
1092
;;------------------------------------------------------------------------------------------------;;
-
 
1093
;< eax = 0 / pointer to encoded data                                                              ;;
-
 
1094
;< ecx = error code / the size of encoded data                                                    ;;
-
 
1095
;;================================================================================================;;
-
 
1096
locals
-
 
1097
	encoded_file rd 1
1078
 
1098
	encoded_file_size rd 1
-
 
1099
	simag png_image
-
 
1100
endl
-
 
1101
	mov ebx,[_img]
-
 
1102
	mov	eax,[ebx+Image.Type]
-
 
1103
	cmp	eax,Image.bpp24
-
 
1104
	je @f
-
 
1105
		mov	ecx,LIBIMG_ERROR_BIT_DEPTH
-
 
1106
		jmp	.error
-
 
1107
	@@:
-
 
1108
 
-
 
1109
	mov edx,ebp
-
 
1110
	sub edx,sizeof.png_image
-
 
1111
	mov dword[edx+png_image.version],PNG_IMAGE_VERSION
-
 
1112
	mov ecx,[ebx+Image.Width]
-
 
1113
	mov [edx+png_image.width],ecx ;Image width in pixels (columns)
-
 
1114
	mov eax,[ebx+Image.Height]
-
 
1115
	mov [edx+png_image.height],eax ;Image height in pixels (rows)
-
 
1116
	mov dword[edx+png_image.format],PNG_COLOR_TYPE_RGB
-
 
1117
	;mov dword[edx+png_image.flags],PNG_IMAGE_FLAG_???
-
 
1118
 
-
 
1119
	imul ecx,3
-
 
1120
	mov edi,ecx
-
 
1121
	imul edi,[ebx+Image.Height]
-
 
1122
	mov [encoded_file_size],edi
-
 
1123
	stdcall [mem.alloc],edi
-
 
1124
	test eax,eax
-
 
1125
	jnz	@f
-
 
1126
		mov	ecx,LIBIMG_ERROR_OUT_OF_MEMORY
-
 
1127
		jmp	.error
-
 
1128
    @@:
-
 
1129
	mov [encoded_file],eax
-
 
1130
	mov edi,edx
-
 
1131
	sub edi,4
-
 
1132
	stdcall png_image_write_to_memory, edx,eax,edi,0,[ebx+Image.Data],ecx,0
-
 
1133
	mov	eax,[encoded_file]
-
 
1134
	mov	ecx,[encoded_file_size]
-
 
1135
	jmp	.quit
-
 
1136
 
1079
img.encode.png:
1137
.error:
-
 
1138
	xor	eax,eax
1080
	xor	eax, eax
1139
.quit:
-
 
1140
	ret
1081
	ret	12
1141
endp