libimg: Add and export img.blend function

git-svn-id: svn://kolibrios.org@8341 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
2020-12-08 17:40:34 +00:00
parent 54712199cb
commit 263f2855f2
35 changed files with 28479 additions and 28388 deletions

View File

@@ -1,2 +1,6 @@
if tup.getconfig("NO_FASM") ~= "" then return end if tup.getconfig("NO_FASM") ~= "" then return end
tup.rule("libimg.asm", "fasm -m 32768 %f %o " .. tup.getconfig("KPACK_CMD"), "libimg.obj") HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_fasm.lua")
add_include(HELPERDIR .. "/develop/libraries/libs-dev/libio")
tup.rule("libimg.asm", FASM .. " -m 32768 %f %o " .. tup.getconfig("KPACK_CMD"), "%B.obj")

View File

@@ -0,0 +1,76 @@
match =MMX, COMPOSITE_MODE {include 'blend_mmx.asm'}
match =SSE, COMPOSITE_MODE {include 'blend_sse.asm'}
;;============================================================================;;
proc img.blend uses ebx esi edi, _bottom, _top, _xbottom, _ybottom, \ ;///////;;
_xtop, _ytop, _width, _height ;//////////////;;
;;----------------------------------------------------------------------------;;
;? Alpha blend _top image to _bottom one (both must be of type Image.bpp32) ;;
;;----------------------------------------------------------------------------;;
;> _bottom = pointer to bottom image (will be changed) ;;
;> _top = pointer to top image (unchanged) ;;
;> _xbottom = x coord inside _bottom image where to put _top image ;;
;> _ybottom = y coord inside _bottom image where to put _top image ;;
;> _xtop = x coord inside _top image to start from ;;
;> _ytop = y coord inside _top image to start from ;;
;> _width = width of _top image area to put to _bottom image ;;
;> _height = height of _top image area to put to _bottom image ;;
;;----------------------------------------------------------------------------;;
;< eax = 0 (fail) / _bottom (ok) ;;
;;============================================================================;;
mov esi, [_top]
mov edi, [_bottom]
mov eax, [esi+Image.Width]
sub eax, [_width]
shl eax, 2
push eax
mov eax, [edi+Image.Width]
sub eax, [_width]
shl eax, 2
push eax
mov eax, [_ytop]
imul eax, [esi+Image.Width]
add eax, [_xtop]
shl eax, 2
mov esi, [esi+Image.Data]
add esi, eax
mov eax, [_ybottom]
imul eax, [edi+Image.Width]
add eax, [_xbottom]
shl eax, 2
mov edi, [edi+Image.Data]
add edi, eax
stdcall xcf._.composite_rgb_00, [_width], [_height]
mov eax, [_bottom]
ret
endp
xcf._.composite_table.begin:
.p00 dd 00, xcf._.composite_rgb_00, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Normal
.p01 dd 01, xcf._.composite_rgb_01, xcf._.composite_gray_01, xcf._.composite_gray_01 ; Dissolve : random dithering to discrete alpha
; .p02 dd 02, xcf._.composite_rgb_02, 0, xcf._.composite_indexed_02 ; Behind : not selectable in the GIMP UI. not implemented
.p03 dd 03, xcf._.composite_rgb_03, xcf._.composite_rgb_03, xcf._.composite_indexed_00 ; Multiply
.p04 dd 04, xcf._.composite_rgb_04, xcf._.composite_rgb_04, xcf._.composite_indexed_00 ; Screen
.p05 dd 05, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Overlay
.p06 dd 06, xcf._.composite_rgb_06, xcf._.composite_rgb_06, xcf._.composite_indexed_00 ; Difference
.p07 dd 07, xcf._.composite_rgb_07, xcf._.composite_rgb_07, xcf._.composite_indexed_00 ; Addition
.p08 dd 08, xcf._.composite_rgb_08, xcf._.composite_rgb_08, xcf._.composite_indexed_00 ; Subtract
.p09 dd 09, xcf._.composite_rgb_09, xcf._.composite_rgb_09, xcf._.composite_indexed_00 ; Darken Only
.p10 dd 10, xcf._.composite_rgb_10, xcf._.composite_rgb_10, xcf._.composite_indexed_00 ; Lighten Only
.p11 dd 11, xcf._.composite_rgb_11, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Hue (H of HSV)
.p12 dd 12, xcf._.composite_rgb_12, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Saturation (S of HSV)
.p13 dd 13, xcf._.composite_rgb_13, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Color (H and S of HSL)
.p14 dd 14, xcf._.composite_rgb_14, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Value (V of HSV)
.p15 dd 15, xcf._.composite_rgb_15, xcf._.composite_rgb_15, xcf._.composite_indexed_00 ; Divide
.p16 dd 16, xcf._.composite_rgb_16, xcf._.composite_rgb_16, xcf._.composite_indexed_00 ; Dodge
.p17 dd 17, xcf._.composite_rgb_17, xcf._.composite_rgb_17, xcf._.composite_indexed_00 ; Burn
.p18 dd 18, xcf._.composite_rgb_18, xcf._.composite_rgb_18, xcf._.composite_indexed_00 ; Hard Light
.p19 dd 19, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Soft Light : XCF >= 2 only ('soft light' == 'overlay')
.p20 dd 20, xcf._.composite_rgb_20, xcf._.composite_rgb_20, xcf._.composite_indexed_00 ; Grain Extract : XCF >= 2 only
.p21 dd 21, xcf._.composite_rgb_21, xcf._.composite_rgb_21, xcf._.composite_indexed_00 ; Grain Merge : XCF >= 2 only
xcf._.composite_table.end:

View File

@@ -1,3 +1,22 @@
;;================================================================================================;;
;;//// blend_mmx.asm //// (c) dunkaist, 2011-2012 ////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;;
;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
proc xcf._.blend_rgb proc xcf._.blend_rgb
xchg al, bh xchg al, bh

View File

@@ -1,3 +1,22 @@
;;================================================================================================;;
;;//// blend_sse.asm //// (c) dunkaist, 2011-2012 ////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;;
;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;;
;;================================================================================================;;
proc xcf._.blend_rgb proc xcf._.blend_rgb
push eax ebx push eax ebx

File diff suppressed because it is too large Load Diff

View File

@@ -1,107 +1,107 @@
;;================================================================================================;; ;;================================================================================================;;
;;//// bmp.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;; ;;//// bmp.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;; ;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;; ;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; ;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;; ;; of the License, or (at your option) any later version. ;;
;; ;; ;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; ;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; ;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;; ;; Lesser General Public License for more details. ;;
;; ;; ;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; ;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;; ;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
struct bmp.FileHeader struct bmp.FileHeader
Type dw ? ; File type, always 4D42h ("BM") Type dw ? ; File type, always 4D42h ("BM")
Size dd ? ; Size of the file in bytes Size dd ? ; Size of the file in bytes
dw 2 dup(?) ; Reserved; must be set to zero. dw 2 dup(?) ; Reserved; must be set to zero.
OffBits dd ? ; Starting position of image data in bytes OffBits dd ? ; Starting position of image data in bytes
ends ends
struct bmp.InfoHeader struct bmp.InfoHeader
; v2 (Windows 2.x) ; v2 (Windows 2.x)
Size dd ? ; Size of this header in bytes Size dd ? ; Size of this header in bytes
union union
struct ; new format struct ; new format
Width dd ? ; Image width in pixels Width dd ? ; Image width in pixels
Height dd ? ; Image height in pixels Height dd ? ; Image height in pixels
Planes dw ? ; Number of color planes Planes dw ? ; Number of color planes
BitCount dw ? ; Number of bits per pixel BitCount dw ? ; Number of bits per pixel
ends ends
struct ; old format struct ; old format
OldWidth dw ? ; Image width in pixels as word OldWidth dw ? ; Image width in pixels as word
OldHeight dw ? ; Image height in pixels as word OldHeight dw ? ; Image height in pixels as word
OldPlanes dw ? ; Number of color planes OldPlanes dw ? ; Number of color planes
OldBitCount dw ? ; Number of bits per pixel OldBitCount dw ? ; Number of bits per pixel
ends ends
ends ends
; v3 (Windows 3.x) ; v3 (Windows 3.x)
Compression dd ? ; Compression method used Compression dd ? ; Compression method used
SizeImage dd ? ; Size of bitmap in bytes SizeImage dd ? ; Size of bitmap in bytes
XPelsPerMeter dd ? ; Horizontal resolution in pixels per meter XPelsPerMeter dd ? ; Horizontal resolution in pixels per meter
YPelsPerMeter dd ? ; Vertical resolution in pixels per meter YPelsPerMeter dd ? ; Vertical resolution in pixels per meter
ClrUsed dd ? ; Number of colors in the image ClrUsed dd ? ; Number of colors in the image
ClrImportant dd ? ; Minimum number of important colors ClrImportant dd ? ; Minimum number of important colors
union union
Palette dd ? ; Image palette if BitCount in [1,4,8] Palette dd ? ; Image palette if BitCount in [1,4,8]
; v4 (Windows 95) ; v4 (Windows 95)
struct struct
RedMask dd ? ; Mask identifying bits of red component RedMask dd ? ; Mask identifying bits of red component
GreenMask dd ? ; Mask identifying bits of green component GreenMask dd ? ; Mask identifying bits of green component
BlueMask dd ? ; Mask identifying bits of blue component BlueMask dd ? ; Mask identifying bits of blue component
AlphaMask dd ? ; Mask identifying bits of alpha component AlphaMask dd ? ; Mask identifying bits of alpha component
CSType dd ? ; Color space type CSType dd ? ; Color space type
RedX dd ? ; X coordinate of red endpoint RedX dd ? ; X coordinate of red endpoint
RedY dd ? ; Y coordinate of red endpoint RedY dd ? ; Y coordinate of red endpoint
RedZ dd ? ; Z coordinate of red endpoint RedZ dd ? ; Z coordinate of red endpoint
GreenX dd ? ; X coordinate of green endpoint GreenX dd ? ; X coordinate of green endpoint
GreenY dd ? ; Y coordinate of green endpoint GreenY dd ? ; Y coordinate of green endpoint
GreenZ dd ? ; Z coordinate of green endpoint GreenZ dd ? ; Z coordinate of green endpoint
BlueX dd ? ; X coordinate of blue endpoint BlueX dd ? ; X coordinate of blue endpoint
BlueY dd ? ; Y coordinate of blue endpoint BlueY dd ? ; Y coordinate of blue endpoint
BlueZ dd ? ; Z coordinate of blue endpoint BlueZ dd ? ; Z coordinate of blue endpoint
GammaRed dd ? ; Gamma red coordinate scale value GammaRed dd ? ; Gamma red coordinate scale value
GammaGreen dd ? ; Gamma green coordinate scale value GammaGreen dd ? ; Gamma green coordinate scale value
GammaBlue dd ? ; Gamma blue coordinate scale value GammaBlue dd ? ; Gamma blue coordinate scale value
ends ends
ends ends
ends ends
define bmp.BI_RGB 0 define bmp.BI_RGB 0
define bmp.BI_RLE8 1 define bmp.BI_RLE8 1
define bmp.BI_RLE4 2 define bmp.BI_RLE4 2
define bmp.BI_BITFIELDS 3 define bmp.BI_BITFIELDS 3
define bmp.BI_JPEG 4 define bmp.BI_JPEG 4
define bmp.BI_PNG 5 define bmp.BI_PNG 5
struct bmp.Header struct bmp.Header
file bmp.FileHeader file bmp.FileHeader
info bmp.InfoHeader info bmp.InfoHeader
ends ends
struct bmp.RgbByteQuad struct bmp.RgbByteQuad
Red db ? Red db ?
Green db ? Green db ?
Blue db ? Blue db ?
Alpha db ? Alpha db ?
ends ends
struct bmp.RgbQuad struct bmp.RgbQuad
Red dd ? Red dd ?
Green dd ? Green dd ?
Blue dd ? Blue dd ?
Alpha dd ? Alpha dd ?
ends ends
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
struct bmp.Image struct bmp.Image
info bmp.InfoHeader info bmp.InfoHeader
ends ends

File diff suppressed because it is too large Load Diff

View File

@@ -1,142 +1,142 @@
;;================================================================================================;; ;;================================================================================================;;
;;//// gif.inc //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;; ;;//// gif.inc //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;; ;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;; ;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; ;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;; ;; of the License, or (at your option) any later version. ;;
;; ;; ;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; ;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; ;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;; ;; Lesser General Public License for more details. ;;
;; ;; ;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; ;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;; ;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
struct gif.FileHeader ; GIF87a struct gif.FileHeader ; GIF87a
Signature db 3 dup(?) ; Header Signature (always "GIF") Signature db 3 dup(?) ; Header Signature (always "GIF")
Version db 3 dup(?) ; GIF format version("87a" or "89a") Version db 3 dup(?) ; GIF format version("87a" or "89a")
ends ends
struct gif.LogicalScreenDescriptor ; GIF87a struct gif.LogicalScreenDescriptor ; GIF87a
ScreenWidth dw ? ; Width of Display Screen in Pixels ScreenWidth dw ? ; Width of Display Screen in Pixels
ScreenHeight dw ? ; Height of Display Screen in Pixels ScreenHeight dw ? ; Height of Display Screen in Pixels
Packed db ? ; Screen and Color Map Information Packed db ? ; Screen and Color Map Information
BackgroundColor db ? ; Background Color Index BackgroundColor db ? ; Background Color Index
AspectRatio db ? ; Pixel Aspect Ratio AspectRatio db ? ; Pixel Aspect Ratio
ends ends
gif.LSD.Packed.SizeOfGlobalColorTableMask = 000000111b gif.LSD.Packed.SizeOfGlobalColorTableMask = 000000111b
gif.LSD.Packed.SizeOfGlobalColorTableShift = 0 gif.LSD.Packed.SizeOfGlobalColorTableShift = 0
gif.LSD.Packed.ColorTableSortFlag = 000001000b gif.LSD.Packed.ColorTableSortFlag = 000001000b
gif.LSD.Packed.ColorTableSortShift = 3 gif.LSD.Packed.ColorTableSortShift = 3
gif.LSD.Packed.ColorResolutionMask = 001110000b gif.LSD.Packed.ColorResolutionMask = 001110000b
gif.LSD.Packed.ColorResolutionShift = 4 gif.LSD.Packed.ColorResolutionShift = 4
gif.LSD.Packed.GlobalColorTableFlag = 010000000b gif.LSD.Packed.GlobalColorTableFlag = 010000000b
gif.LSD.Packed.GlobalColorTableShift = 7 gif.LSD.Packed.GlobalColorTableShift = 7
struct gif.Header struct gif.Header
file gif.FileHeader file gif.FileHeader
lsd gif.LogicalScreenDescriptor lsd gif.LogicalScreenDescriptor
ends ends
struct gif.RgbTriplet ; GIF87a struct gif.RgbTriplet ; GIF87a
Red db ? ; Red Color Element Red db ? ; Red Color Element
Green db ? ; Green Color Element Green db ? ; Green Color Element
Blue db ? ; Blue Color Element Blue db ? ; Blue Color Element
ends ends
struct gif.Block struct gif.Block
Introducer db ? Introducer db ?
ends ends
gif.Block.Introducer.EndOfData = 0x00 gif.Block.Introducer.EndOfData = 0x00
gif.Block.Introducer.Extension = 0x21 gif.Block.Introducer.Extension = 0x21
gif.Block.Introducer.ImageDescriptor = 0x2C gif.Block.Introducer.ImageDescriptor = 0x2C
gif.Block.Introducer.EndOfFile = 0x3B gif.Block.Introducer.EndOfFile = 0x3B
struct gif.ImageDescriptor ; GIF87a struct gif.ImageDescriptor ; GIF87a
; we read Introducer before parsing gif.ImageDescriptor, ; we read Introducer before parsing gif.ImageDescriptor,
; so it is convenient to not include it in struct ; so it is convenient to not include it in struct
; b gif.Block ; Introducer = 2Ch (',') ; b gif.Block ; Introducer = 2Ch (',')
Left dw ? ; X position of image on the display Left dw ? ; X position of image on the display
Top dw ? ; Y position of image on the display Top dw ? ; Y position of image on the display
Width dw ? ; Width of the image in pixels Width dw ? ; Width of the image in pixels
Height dw ? ; Height of the image in pixels Height dw ? ; Height of the image in pixels
Packed db ? ; Image and Color Table Data Information Packed db ? ; Image and Color Table Data Information
ends ends
gif.ID.Packed.SizeOfLocalColorTableMask = 000000111b gif.ID.Packed.SizeOfLocalColorTableMask = 000000111b
gif.ID.Packed.SizeOfLocalColorTableShift = 0 gif.ID.Packed.SizeOfLocalColorTableShift = 0
gif.ID.Packed.SortFlag = 000100000b gif.ID.Packed.SortFlag = 000100000b
gif.ID.Packed.SortShift = 5 gif.ID.Packed.SortShift = 5
gif.ID.Packed.InterleaceFlag = 001000000b gif.ID.Packed.InterleaceFlag = 001000000b
gif.ID.Packed.InterleaceShift = 6 gif.ID.Packed.InterleaceShift = 6
gif.ID.Packed.LocalColorTableFlag = 010000000b gif.ID.Packed.LocalColorTableFlag = 010000000b
gif.ID.Packed.LocalColorTableShift = 7 gif.ID.Packed.LocalColorTableShift = 7
struct gif.Extension struct gif.Extension
b gif.Block ; Introducer = 21h ('|') b gif.Block ; Introducer = 21h ('|')
Label db ? ; Extension label Label db ? ; Extension label
ends ends
gif.Extension.Label.PlainText = 0x01 gif.Extension.Label.PlainText = 0x01
gif.Extension.Label.GraphicsControl = 0xF9 gif.Extension.Label.GraphicsControl = 0xF9
gif.Extension.Label.Comment = 0xFE gif.Extension.Label.Comment = 0xFE
gif.Extension.Label.Application = 0xFF gif.Extension.Label.Application = 0xFF
struct gif.PlainTextExtension ; GIF89a struct gif.PlainTextExtension ; GIF89a
; e gif.Extension ; Label = 01h ; e gif.Extension ; Label = 01h
; BlockSize db ? ; Size of Extension Block (always 0Ch) ; BlockSize db ? ; Size of Extension Block (always 0Ch)
TextGridLeft dw ? ; X position of text grid in pixels TextGridLeft dw ? ; X position of text grid in pixels
TextGridTop dw ? ; Y position of text grid in pixels TextGridTop dw ? ; Y position of text grid in pixels
TextGridWidth dw ? ; Width of the text grid in pixels TextGridWidth dw ? ; Width of the text grid in pixels
TextGridHeight dw ? ; Height of the text grid in pixels TextGridHeight dw ? ; Height of the text grid in pixels
CellWidth db ? ; Width of a grid cell in pixels CellWidth db ? ; Width of a grid cell in pixels
CellHeight db ? ; Height of a grid cell in pixels CellHeight db ? ; Height of a grid cell in pixels
TextFgColorIndex db ? ; Text foreground color index value TextFgColorIndex db ? ; Text foreground color index value
TextBgColorIndex db ? ; Text background color index value TextBgColorIndex db ? ; Text background color index value
PlainTextData db ? ; The Plain Text data (*) PlainTextData db ? ; The Plain Text data (*)
; Terminator db ? ; Block Terminator (always 0) ; Terminator db ? ; Block Terminator (always 0)
ends ends
struct gif.GraphicsControlExtension ; GIF89a struct gif.GraphicsControlExtension ; GIF89a
; e gif.Extension ; Label = F9h ; e gif.Extension ; Label = F9h
; BlockSize db ? ; Size of remaining fields (always 04h) ; BlockSize db ? ; Size of remaining fields (always 04h)
; previous fields are not included in this structure for convenience ; previous fields are not included in this structure for convenience
; (they are parsed before this) ; (they are parsed before this)
Packed db ? ; Method of graphics disposal to use Packed db ? ; Method of graphics disposal to use
DelayTime dw ? ; Hundredths of seconds to wait DelayTime dw ? ; Hundredths of seconds to wait
ColorIndex db ? ; Transparent Color Index ColorIndex db ? ; Transparent Color Index
; Terminator db ? ; Block Terminator (always 0) ; Terminator db ? ; Block Terminator (always 0)
ends ends
struct gif.CommentExtension ; GIF89a struct gif.CommentExtension ; GIF89a
e gif.Extension ; Label = FEh e gif.Extension ; Label = FEh
CommentData db ? ; Pointer to Comment Data sub-blocks (*) CommentData db ? ; Pointer to Comment Data sub-blocks (*)
; Terminator db ? ; Block Terminator (always 0) ; Terminator db ? ; Block Terminator (always 0)
ends ends
struct gif.ApplicationExtension ; GIF89a struct gif.ApplicationExtension ; GIF89a
e gif.Extension ; Label = FFh e gif.Extension ; Label = FFh
BlockSize db ? ; Size of Extension Block (always 0Bh) BlockSize db ? ; Size of Extension Block (always 0Bh)
Identifier db 8 dup(?) ; Application Identifier Identifier db 8 dup(?) ; Application Identifier
AuthentCode db 3 dup(?) ; Application Authentication Code AuthentCode db 3 dup(?) ; Application Authentication Code
ApplicationData db ? ; Point to Application Data sub-blocks (*) ApplicationData db ? ; Point to Application Data sub-blocks (*)
; Terminator db ? ; Block Terminator (always 0) ; Terminator db ? ; Block Terminator (always 0)
ends ends
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
struct gif.Image struct gif.Image
info gif.ImageDescriptor info gif.ImageDescriptor
gce gif.GraphicsControlExtension gce gif.GraphicsControlExtension
; lsd gif.LogicalScreenDescriptor ; saved only in first image ; lsd gif.LogicalScreenDescriptor ; saved only in first image
ends ends
gif.Null equ 0x1000 gif.Null equ 0x1000

View File

@@ -1,372 +1,372 @@
;;================================================================================================;; ;;================================================================================================;;
;;//// ico.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;; ;;//// ico.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;; ;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;; ;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; ;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;; ;; of the License, or (at your option) any later version. ;;
;; ;; ;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; ;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; ;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;; ;; Lesser General Public License for more details. ;;
;; ;; ;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; ;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;; ;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; References: ;; ;; References: ;;
;; 1. "Icons in Win32" ;; ;; 1. "Icons in Win32" ;;
;; by John Hornick, Microsoft Corporation ;; ;; by John Hornick, Microsoft Corporation ;;
;; http://msdn2.microsoft.com/en-us/library/ms997538.aspx ;; ;; http://msdn2.microsoft.com/en-us/library/ms997538.aspx ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
include 'ico_cur.inc' include 'ico_cur.inc'
;;================================================================================================;; ;;================================================================================================;;
;;proc img.is.ico _data, _length ;////////////////////////////////////////////////////////////////;; ;;proc img.is.ico _data, _length ;////////////////////////////////////////////////////////////////;;
img.is.ico: img.is.ico:
mov edx, 0x00010000 ; icon type = 1 mov edx, 0x00010000 ; icon type = 1
jmp @f jmp @f
img.is.cur: img.is.cur:
mov edx, 0x00020000 ; cursor type = 2 mov edx, 0x00020000 ; cursor type = 2
@@: @@:
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;? Determine if raw data could be decoded (is in ICO format) ;; ;? Determine if raw data could be decoded (is in ICO format) ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;> _data = raw data as read from file/stream ;; ;> _data = raw data as read from file/stream ;;
;> _length = data length ;; ;> _length = data length ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;; ;< eax = false / true ;;
;;================================================================================================;; ;;================================================================================================;;
; test 1 (length of data): data must contain FileHeader ; test 1 (length of data): data must contain FileHeader
mov ecx, [esp+8] mov ecx, [esp+8]
sub ecx, sizeof.ico.FileHeader sub ecx, sizeof.ico.FileHeader
jb .nope jb .nope
; test 2: signature ; test 2: signature
mov eax, [esp+4] mov eax, [esp+4]
cmp dword [eax], edx ; Reserved & Type cmp dword [eax], edx ; Reserved & Type
jne .nope jne .nope
; test 3: count must be non-zero ; test 3: count must be non-zero
movzx eax, [eax + ico.FileHeader.Count] movzx eax, [eax + ico.FileHeader.Count]
test eax, eax test eax, eax
jz .nope jz .nope
; test 4 (length of data): data must containt Count dir entries ; test 4 (length of data): data must containt Count dir entries
shl eax, 4 shl eax, 4
sub ecx, eax sub ecx, eax
jae .yep jae .yep
.nope: .nope:
xor eax, eax xor eax, eax
ret 8 ret 8
.yep: .yep:
xor eax, eax xor eax, eax
inc eax inc eax
ret 8 ret 8
;endp ;endp
;;================================================================================================;; ;;================================================================================================;;
proc img.decode.ico_cur _data, _length, _options ;////////////////////////////////////////////////;; proc img.decode.ico_cur _data, _length, _options ;////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;? Decode data into image if it contains correctly formed raw data in ICO/CUR format ;; ;? Decode data into image if it contains correctly formed raw data in ICO/CUR format ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;> _data = raw data as read from file/stream ;; ;> _data = raw data as read from file/stream ;;
;> _length = data length ;; ;> _length = data length ;;
;> _options = options for decoding (e.g. background color) ;; ;> _options = options for decoding (e.g. background color) ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) or pointer to image ;; ;< eax = 0 (error) or pointer to image ;;
;;================================================================================================;; ;;================================================================================================;;
locals locals
count dd ? count dd ?
img dd ? img dd ?
main_img dd ? main_img dd ?
endl endl
push ebx esi edi push ebx esi edi
; img.is.ico has been already called by img.decode ; img.is.ico has been already called by img.decode
; stdcall img.is.ico, [_data], [_length] ; stdcall img.is.ico, [_data], [_length]
; or eax, eax ; or eax, eax
; jz .error ; jz .error
mov ebx, [_data] mov ebx, [_data]
movzx eax, [ebx + ico.FileHeader.Count] movzx eax, [ebx + ico.FileHeader.Count]
mov [count], eax mov [count], eax
and [img], 0 and [img], 0
and [main_img], 0 and [main_img], 0
.loop: .loop:
mov ecx, [ebx + sizeof.ico.FileHeader + ico.DirEntry.ByteSize] mov ecx, [ebx + sizeof.ico.FileHeader + ico.DirEntry.ByteSize]
mov edx, [ebx + sizeof.ico.FileHeader + ico.DirEntry.ImageOffset] mov edx, [ebx + sizeof.ico.FileHeader + ico.DirEntry.ImageOffset]
mov eax, [_length] mov eax, [_length]
sub eax, edx sub eax, edx
jb .skip jb .skip
cmp eax, ecx cmp eax, ecx
jb .skip jb .skip
cmp ecx, 12 ; length test, see img.is.bmp cmp ecx, 12 ; length test, see img.is.bmp
jb .skip jb .skip
add edx, [_data] add edx, [_data]
push [_options] push [_options]
push ecx push ecx
push edx push edx
call img.decode.ico._.decode_icon_data call img.decode.ico._.decode_icon_data
test eax, eax test eax, eax
jz .skip jz .skip
push 0xFFFFFF ; set bgr to white if no given push 0xFFFFFF ; set bgr to white if no given
mov edx, [_options] mov edx, [_options]
test edx, edx test edx, edx
jz @f jz @f
cmp [edx + ImageDecodeOptions.UsedSize], ImageDecodeOptions.BackgroundColor + 4 cmp [edx + ImageDecodeOptions.UsedSize], ImageDecodeOptions.BackgroundColor + 4
jb @f jb @f
add esp, 4 add esp, 4
push [edx + ImageDecodeOptions.BackgroundColor] push [edx + ImageDecodeOptions.BackgroundColor]
@@: @@:
call img.decode.ico._.decode_icon_mask call img.decode.ico._.decode_icon_mask
test eax, eax test eax, eax
jz .skip jz .skip
mov edx, [img] mov edx, [img]
test edx, edx test edx, edx
jz .first jz .first
mov [edx + Image.Next], eax mov [edx + Image.Next], eax
mov [eax + Image.Previous], edx mov [eax + Image.Previous], edx
jmp @f jmp @f
.first: .first:
mov [main_img], eax mov [main_img], eax
@@: @@:
mov [img], eax mov [img], eax
.skip: .skip:
add ebx, sizeof.ico.DirEntry add ebx, sizeof.ico.DirEntry
dec [count] dec [count]
jnz .loop jnz .loop
mov eax, [main_img] mov eax, [main_img]
pop edi esi ebx pop edi esi ebx
ret ret
endp endp
;;================================================================================================;; ;;================================================================================================;;
img.encode.cur: img.encode.cur:
proc img.encode.ico _img, _p_length, _options ;///////////////////////////////////////////////////;; proc img.encode.ico _img, _p_length, _options ;///////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;? Encode image into raw data in ICO format ;; ;? Encode image into raw data in ICO format ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;> _img = pointer to image ;; ;> _img = pointer to image ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) or pointer to encoded data ;; ;< eax = 0 (error) or pointer to encoded data ;;
;< _p_length = encoded data length ;; ;< _p_length = encoded data length ;;
;;================================================================================================;; ;;================================================================================================;;
xor eax, eax xor eax, eax
ret ret
endp endp
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;! Below are private procs you should never call directly from your code ;; ;! Below are private procs you should never call directly from your code ;;
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
img.decode.ico._.decode_icon_data: img.decode.ico._.decode_icon_data:
; create stack frame and jump to common BMP+ICO code ; create stack frame and jump to common BMP+ICO code
push ebp push ebp
mov ebp, esp mov ebp, esp
sub esp, 12 sub esp, 12
mov byte [ebp - 3], 1 ; bIsIco mov byte [ebp - 3], 1 ; bIsIco
jmp img.decode.bmp.common jmp img.decode.bmp.common
img.decode.ico._.decode_icon_mask: img.decode.ico._.decode_icon_mask:
mov edx, [eax + Image.Width] mov edx, [eax + Image.Width]
add edx, 31 add edx, 31
shr edx, 3 shr edx, 3
and edx, not 3 and edx, not 3
push edx push edx
imul edx, [eax + Image.Height] imul edx, [eax + Image.Height]
cmp ecx, edx cmp ecx, edx
pop edx pop edx
jb .error.free jb .error.free
mov edi, [eax + Image.Data] mov edi, [eax + Image.Data]
push ebp ebx eax push ebp ebx eax
xor ebp, ebp xor ebp, ebp
mov ebx, [eax + Image.Extended] mov ebx, [eax + Image.Extended]
cmp [ebx + bmp.Image.info.Height], 0 cmp [ebx + bmp.Image.info.Height], 0
js @f js @f
push edx push edx
imul edx, [eax + Image.Height] imul edx, [eax + Image.Height]
add esi, edx add esi, edx
pop edx pop edx
lea ebp, [edx+edx] lea ebp, [edx+edx]
sub esi, edx sub esi, edx
@@: @@:
mov ebx, [eax + Image.Height] mov ebx, [eax + Image.Height]
mov ecx, [eax + Image.Width] mov ecx, [eax + Image.Width]
; for now, BMP code produces only 8 and 32 bpp images ; for now, BMP code produces only 8 and 32 bpp images
cmp [eax + Image.Type], Image.bpp8i cmp [eax + Image.Type], Image.bpp8i
jz .bpp8 jz .bpp8
.bpp32: .bpp32:
mov edx, [esp+16] ; get background color mov edx, [esp+16] ; get background color
.bpp32.extloop: .bpp32.extloop:
push ecx push ecx
.bpp32.innloop: .bpp32.innloop:
lodsd lodsd
bswap eax bswap eax
push 32 push 32
.bpp32.dwordloop: .bpp32.dwordloop:
add eax, eax add eax, eax
jnc @f jnc @f
mov [edi], edx mov [edi], edx
@@: @@:
add edi, 4 add edi, 4
dec ecx dec ecx
jz @f jz @f
dec dword [esp] dec dword [esp]
jnz .bpp32.dwordloop jnz .bpp32.dwordloop
@@: @@:
pop eax pop eax
test ecx, ecx test ecx, ecx
jnz .bpp32.innloop jnz .bpp32.innloop
sub esi, ebp sub esi, ebp
pop ecx pop ecx
dec ebx dec ebx
jnz .bpp32.extloop jnz .bpp32.extloop
pop eax ebx ebp pop eax ebx ebp
ret 4 ret 4
.bpp8: .bpp8:
push edi push edi
mov edi, [eax + Image.Palette] mov edi, [eax + Image.Palette]
mov eax, [esp+20] ; get background color mov eax, [esp+20] ; get background color
; if palette already has index for bgr color, use it ; if palette already has index for bgr color, use it
push ecx push ecx
mov ecx, 256 mov ecx, 256
repnz scasd repnz scasd
jnz .bpp8.notfound jnz .bpp8.notfound
not cl ; cl = index not cl ; cl = index
pop edx pop edx
pop edi pop edi
.bpp8.extloop: .bpp8.extloop:
push edx push edx
.bpp8.innloop: .bpp8.innloop:
lodsd lodsd
bswap eax bswap eax
push 32 push 32
.bpp8.dwordloop: .bpp8.dwordloop:
add eax, eax add eax, eax
jnc @f jnc @f
mov [edi], cl mov [edi], cl
@@: @@:
inc edi inc edi
dec edx dec edx
jz @f jz @f
dec dword [esp] dec dword [esp]
jnz .bpp8.dwordloop jnz .bpp8.dwordloop
@@: @@:
pop eax pop eax
test edx, edx test edx, edx
jnz .bpp8.innloop jnz .bpp8.innloop
sub esi, ebp sub esi, ebp
pop edx pop edx
dec ebx dec ebx
jnz .bpp8.extloop jnz .bpp8.extloop
pop eax ebx ebp pop eax ebx ebp
ret 4 ret 4
.bpp8.notfound: .bpp8.notfound:
; get maximum used color; if index < 255, then we can add one color to palette ; get maximum used color; if index < 255, then we can add one color to palette
pop ecx pop ecx
pop edi pop edi
pop eax pop eax
mov edx, [eax + Image.Width] mov edx, [eax + Image.Width]
imul edx, ebx imul edx, ebx
mov edi, [eax + Image.Data] mov edi, [eax + Image.Data]
xor ecx, ecx xor ecx, ecx
.bpp8.scanloop: .bpp8.scanloop:
cmp [edi], cl cmp [edi], cl
jb @f jb @f
mov cl, [edi] mov cl, [edi]
@@: @@:
inc edi inc edi
dec edx dec edx
jnz .bpp8.scanloop jnz .bpp8.scanloop
inc cl inc cl
jz .bpp8.nospace jz .bpp8.nospace
mov edx, [esp+8] mov edx, [esp+8]
mov edi, [eax + Image.Palette] mov edi, [eax + Image.Palette]
mov [edi+ecx*4], edx ; set palette color mov [edi+ecx*4], edx ; set palette color
mov edi, [eax + Image.Data] mov edi, [eax + Image.Data]
mov edx, [eax + Image.Width] mov edx, [eax + Image.Width]
push eax push eax
jmp .bpp8.extloop jmp .bpp8.extloop
.bpp8.nospace: .bpp8.nospace:
; convert to 24 bpp ; convert to 24 bpp
mov edx, [eax + Image.Width] mov edx, [eax + Image.Width]
imul edx, ebx imul edx, ebx
lea edx, [edx*3] lea edx, [edx*3]
push eax push eax
invoke mem.alloc, edx invoke mem.alloc, edx
mov edi, eax mov edi, eax
pop eax pop eax
test edi, edi test edi, edi
jz .error.free2 jz .error.free2
push eax esi edi push eax esi edi
mov esi, eax mov esi, eax
call img._.do_rgb call img._.do_rgb
pop edi esi eax pop edi esi eax
xchg edi, [eax + Image.Data] xchg edi, [eax + Image.Data]
mov byte [eax + Image.Type], Image.bpp24 mov byte [eax + Image.Type], Image.bpp24
push eax push eax
invoke mem.free, edi invoke mem.free, edi
pop eax pop eax
push eax push eax
mov ecx, [eax + Image.Width] mov ecx, [eax + Image.Width]
mov edi, [eax + Image.Data] mov edi, [eax + Image.Data]
.bpp24: .bpp24:
mov edx, [esp+16] ; get background color mov edx, [esp+16] ; get background color
.bpp24.extloop: .bpp24.extloop:
push ecx push ecx
.bpp24.innloop: .bpp24.innloop:
lodsd lodsd
bswap eax bswap eax
push 32 push 32
.bpp24.dwordloop: .bpp24.dwordloop:
add eax, eax add eax, eax
jnc @f jnc @f
mov [edi], dx mov [edi], dx
ror edx, 16 ror edx, 16
mov [edi+2], dl mov [edi+2], dl
ror edx, 16 ror edx, 16
@@: @@:
add edi, 3 add edi, 3
dec ecx dec ecx
jz @f jz @f
dec dword [esp] dec dword [esp]
jnz .bpp24.dwordloop jnz .bpp24.dwordloop
@@: @@:
pop eax pop eax
test ecx, ecx test ecx, ecx
jnz .bpp24.innloop jnz .bpp24.innloop
sub esi, ebp sub esi, ebp
pop ecx pop ecx
dec ebx dec ebx
jnz .bpp24.extloop jnz .bpp24.extloop
pop eax ebx ebp pop eax ebx ebp
ret 4 ret 4
.error.free2: .error.free2:
pop ebx ebp pop ebx ebp
.error.free: .error.free:
stdcall img._.delete, eax stdcall img._.delete, eax
xor eax, eax xor eax, eax
ret 4 ret 4
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;! Below is private data you should never use directly from your code ;; ;! Below is private data you should never use directly from your code ;;
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
; ;

View File

@@ -1,46 +1,46 @@
;;================================================================================================;; ;;================================================================================================;;
;;//// ico.inc //// (c) diamond, 2009 ////////////////////////////////////////////////////////////;; ;;//// ico.inc //// (c) diamond, 2009 ////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;; ;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;; ;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; ;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;; ;; of the License, or (at your option) any later version. ;;
;; ;; ;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; ;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; ;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;; ;; Lesser General Public License for more details. ;;
;; ;; ;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; ;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;; ;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
struct ico.FileHeader struct ico.FileHeader
Reserved dw ? ; must be 0 Reserved dw ? ; must be 0
Type dw ? ; must be 1 Type dw ? ; must be 1
Count dw ? Count dw ?
ends ends
struct ico.DirEntry struct ico.DirEntry
Width db ? Width db ?
Height db ? Height db ?
ColorCount db ? ColorCount db ?
db ? ; reseved db ? ; reseved
dw ? ; reserved dw ? ; reserved
dw ? ; reserved dw ? ; reserved
ByteSize dd ? ByteSize dd ?
ImageOffset dd ? ImageOffset dd ?
ends ends
struct cur.DirEntry struct cur.DirEntry
Width db ? Width db ?
Height db ? Height db ?
ColorCount db ? ColorCount db ?
db ? ; reserved db ? ; reserved
XHotSpot dw ? XHotSpot dw ?
YHotSpot dw ? YHotSpot dw ?
ByteSize dd ? ByteSize dd ?
ImageOffset dd ? ImageOffset dd ?
ends ends

File diff suppressed because it is too large Load Diff

View File

@@ -1,96 +1,96 @@
;;================================================================================================;; ;;================================================================================================;;
;;//// jpeg.inc //// (c) diamond, 2008-2009 //////////////////////////////////////////////////////;; ;;//// jpeg.inc //// (c) diamond, 2008-2009 //////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;; ;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;; ;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; ;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;; ;; of the License, or (at your option) any later version. ;;
;; ;; ;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; ;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; ;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;; ;; Lesser General Public License for more details. ;;
;; ;; ;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; ;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;; ;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
struct jpeg.work ; working area for JPEG handling struct jpeg.work ; working area for JPEG handling
image dd ? image dd ?
; progressive JPEG? ; progressive JPEG?
progressive db ? progressive db ?
; one component in the scan? ; one component in the scan?
not_interleaved db ? not_interleaved db ?
; Adobe YCCK file? ; Adobe YCCK file?
adobe_ycck db ? adobe_ycck db ?
rb 1 rb 1
; parameters for progressive scan ; parameters for progressive scan
ScanStart db ? ScanStart db ?
ScanEnd db ? ScanEnd db ?
ApproxPosLow db ? ApproxPosLow db ?
ApproxPosHigh db ? ApproxPosHigh db ?
; restart interval ; restart interval
restart_interval dd ? restart_interval dd ?
decoded_MCUs dd ? decoded_MCUs dd ?
_esp dd ? _esp dd ?
; components information, up to 4 components ; components information, up to 4 components
; db ComponentIdentifier, db V, db H, db VFactor, db HFactor, db QuantizationTable ; db ComponentIdentifier, db V, db H, db VFactor, db HFactor, db QuantizationTable
components rb 4*6 components rb 4*6
max_v db ? max_v db ?
max_h db ? max_h db ?
cur_rst_marker db ? cur_rst_marker db ?
db ? db ?
huffman_bits dd ? huffman_bits dd ?
block_width dd ? block_width dd ?
block_height dd ? block_height dd ?
block_delta_x dd ? block_delta_x dd ?
block_delta_y dd ? block_delta_y dd ?
cur_block_dx dd ? cur_block_dx dd ?
cur_block_dy dd ? cur_block_dy dd ?
x_num_blocks dd ? x_num_blocks dd ?
y_num_blocks dd ? y_num_blocks dd ?
delta_x dd ? delta_x dd ?
delta_y dd ? delta_y dd ?
pixel_size dd ? pixel_size dd ?
line_size dd ? line_size dd ?
cur_x dd ? cur_x dd ?
cur_y dd ? cur_y dd ?
max_x dd ? max_x dd ?
max_y dd ? max_y dd ?
cur_out_ptr dd ? cur_out_ptr dd ?
dct_buffer dd ? dct_buffer dd ?
dct_buffer_size dd ? dct_buffer_size dd ?
;ns dd ? ;ns dd ?
; +0: db V, db H, db VFactor, db HFactor, dd HIncrement, dd VIncrement, ; +0: db V, db H, db VFactor, db HFactor, dd HIncrement, dd VIncrement,
; +12: dd QuantizationTable, dd DCTable, dd ACTable, ; +12: dd QuantizationTable, dd DCTable, dd ACTable,
; +24: dd width/HFactor, dd width/HFactor-8k, dd HFactor+1-(width%HFactor), ; +24: dd width/HFactor, dd width/HFactor-8k, dd HFactor+1-(width%HFactor),
; +36: dd height/VFactor, dd height/VFactor-8m, dd VFactor+1-(height%VFactor), ; +36: dd height/VFactor, dd height/VFactor-8m, dd VFactor+1-(height%VFactor),
; +48: dw DCPrediction, db ?, db (0 for Y, 80h for Cb,Cr), dd ComponentOffset ; +48: dw DCPrediction, db ?, db (0 for Y, 80h for Cb,Cr), dd ComponentOffset
cur_components rb 4*56 cur_components rb 4*56
cur_components_end dd ? cur_components_end dd ?
; Fourier coefficients ; Fourier coefficients
dct_coeff rw 64 dct_coeff rw 64
; Temporary space for IDCT ; Temporary space for IDCT
idct_tmp_area rd 64 idct_tmp_area rd 64
; decoded block 8*8 ; decoded block 8*8
decoded_data rb 8*8 decoded_data rb 8*8
; up to 4 quantization tables ; up to 4 quantization tables
quant_tables rd 4*64 quant_tables rd 4*64
quant_tables_defined rb 4 quant_tables_defined rb 4
; Huffman tables ; Huffman tables
dc_huffman_defined rb 4 dc_huffman_defined rb 4
ac_huffman_defined rb 4 ac_huffman_defined rb 4
; up to 4 DC Huffman tables ; up to 4 DC Huffman tables
;dc_huffman rd 4*256*2 ;dc_huffman rd 4*256*2
; up to 4 AC Huffman tables ; up to 4 AC Huffman tables
;ac_huffman rd 4*256*2 ;ac_huffman rd 4*256*2
max_hufftable_size = (256 + (9+128)*16)*2 max_hufftable_size = (256 + (9+128)*16)*2
dc_huffman rb 4*max_hufftable_size dc_huffman rb 4*max_hufftable_size
ac_huffman rb 4*max_hufftable_size ac_huffman rb 4*max_hufftable_size
ends ends

View File

@@ -22,14 +22,14 @@ format MS COFF
public @EXPORT as 'EXPORTS' public @EXPORT as 'EXPORTS'
include '../../../../struct.inc' include 'struct.inc'
include '../../../../proc32.inc' include 'proc32.inc'
include '../../../../macros.inc' include 'macros.inc'
include '../../../../config.inc' include 'config.inc'
include '../../../../debug-fdo.inc' include 'debug-fdo.inc'
__DEBUG__ = 0 __DEBUG__ = 0
__DEBUG_LEVEL__ = 1 __DEBUG_LEVEL__ = 1
include '../../../../develop/libraries/libs-dev/libio/libio.inc' include 'libio.inc'
purge section,mov,add,sub purge section,mov,add,sub
include 'libimg.inc' include 'libimg.inc'
@@ -53,6 +53,11 @@ include 'xbm/xbm.asm'
include 'scale.asm' include 'scale.asm'
include 'convert.asm' include 'convert.asm'
COMPOSITE_MODE equ MMX
; MMX | pretty fast and compatible
; SSE | a bit faster, but may be unsupported by some CPUs
include 'blend.asm'
;;================================================================================================;; ;;================================================================================================;;
proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;; proc lib_init ;///////////////////////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
@@ -2743,6 +2748,7 @@ img._.get_scanline_len: ;///////////////////////////////////////////////////////
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
section '.data' data readable writable align 16
;include_debug_strings ;include_debug_strings
align 4 align 4
@@ -2807,6 +2813,7 @@ export \
img.scale , 'img_scale' , \ img.scale , 'img_scale' , \
img.get_scaled_size, 'img_get_scaled_size', \ img.get_scaled_size, 'img_get_scaled_size', \
img.convert , 'img_convert' , \ img.convert , 'img_convert' , \
img.blend , 'img_blend' , \
img.formats_table , 'img_formats_table' img.formats_table , 'img_formats_table'
; import from deflate unpacker ; import from deflate unpacker
@@ -2841,7 +2848,6 @@ gif_default_palette:
db 0, 0, 0 db 0, 0, 0
db 0xFF, 0xFF, 0xFF db 0xFF, 0xFF, 0xFF
section '.data' data readable writable align 16
; uninitialized data - global constant tables ; uninitialized data - global constant tables
mem.alloc dd ? mem.alloc dd ?
mem.free dd ? mem.free dd ?

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,253 +1,253 @@
; pnginfo.inc - header file for PNG reference library ; pnginfo.inc - header file for PNG reference library
; Last changed in libpng 1.6.1 [March 28, 2013] ; Last changed in libpng 1.6.1 [March 28, 2013]
; Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson ; Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) ; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) ; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
; This code is released under the libpng license. ; This code is released under the libpng license.
; For conditions of distribution and use, see the disclaimer ; For conditions of distribution and use, see the disclaimer
; and license in png.inc ; and license in png.inc
; png_info is a structure that holds the information in a PNG file so ; png_info is a structure that holds the information in a PNG file so
; that the application can find out the characteristics of the image. ; that the application can find out the characteristics of the image.
; If you are reading the file, this structure will tell you what is ; If you are reading the file, this structure will tell you what is
; in the PNG file. If you are writing the file, fill in the information ; in the PNG file. If you are writing the file, fill in the information
; you want to put into the PNG file, using png_set_*() functions, then ; you want to put into the PNG file, using png_set_*() functions, then
; call png_write_info(). ; call png_write_info().
; The names chosen should be very close to the PNG specification, so ; The names chosen should be very close to the PNG specification, so
; consult that document for information about the meaning of each field. ; consult that document for information about the meaning of each field.
; With libpng < 0.95, it was only possible to directly set and read the ; With libpng < 0.95, it was only possible to directly set and read the
; the values in the png_info_struct, which meant that the contents and ; the values in the png_info_struct, which meant that the contents and
; order of the values had to remain fixed. With libpng 0.95 and later, ; order of the values had to remain fixed. With libpng 0.95 and later,
; however, there are now functions that abstract the contents of ; however, there are now functions that abstract the contents of
; png_info_struct from the application, so this makes it easier to use ; png_info_struct from the application, so this makes it easier to use
; libpng with dynamic libraries, and even makes it possible to use ; libpng with dynamic libraries, and even makes it possible to use
; libraries that don't have all of the libpng ancillary chunk-handing ; libraries that don't have all of the libpng ancillary chunk-handing
; functionality. In libpng-1.5.0 this was moved into a separate private ; functionality. In libpng-1.5.0 this was moved into a separate private
; file that is not visible to applications. ; file that is not visible to applications.
; The following members may have allocated storage attached that should be ; The following members may have allocated storage attached that should be
; cleaned up before the structure is discarded: palette, trans, text, ; cleaned up before the structure is discarded: palette, trans, text,
; pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, ; pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
; splt_palettes, scal_unit, row_pointers, and unknowns. By default, these ; splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
; are automatically freed when the info structure is deallocated, if they were ; are automatically freed when the info structure is deallocated, if they were
; allocated internally by libpng. This behavior can be changed by means ; allocated internally by libpng. This behavior can be changed by means
; of the png_data_freer() function. ; of the png_data_freer() function.
; More allocation details: all the chunk-reading functions that ; More allocation details: all the chunk-reading functions that
; change these members go through the corresponding png_set_* ; change these members go through the corresponding png_set_*
; functions. A function to clear these members is available: see ; functions. A function to clear these members is available: see
; png_free_data(). The png_set_* functions do not depend on being ; png_free_data(). The png_set_* functions do not depend on being
; able to point info structure members to any of the storage they are ; able to point info structure members to any of the storage they are
; passed (they make their own copies), EXCEPT that the png_set_text ; passed (they make their own copies), EXCEPT that the png_set_text
; functions use the same storage passed to them in the text_ptr or ; functions use the same storage passed to them in the text_ptr or
; itxt_ptr structure argument, and the png_set_rows and png_set_unknowns ; itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
; functions do not make their own copies. ; functions do not make their own copies.
struct png_info_def struct png_info_def
; The following are necessary for every PNG file ; The following are necessary for every PNG file
width dd ? ;uint_32 ;width of image in pixels (from IHDR) width dd ? ;uint_32 ;width of image in pixels (from IHDR)
height dd ? ;uint_32 ;height of image in pixels (from IHDR) height dd ? ;uint_32 ;height of image in pixels (from IHDR)
valid dd ? ;uint_32 ;valid chunk data (see PNG_INFO_ below) valid dd ? ;uint_32 ;valid chunk data (see PNG_INFO_ below)
rowbytes dd ? ;png_size_t ;bytes needed to hold an untransformed row rowbytes dd ? ;png_size_t ;bytes needed to hold an untransformed row
palette dd ? ;png_colorp ; array of color values (valid & PNG_INFO_PLTE) palette dd ? ;png_colorp ; array of color values (valid & PNG_INFO_PLTE)
num_palette dw ? ;uint_16 ;number of color entries in "palette" (PLTE) num_palette dw ? ;uint_16 ;number of color entries in "palette" (PLTE)
num_trans dw ? ;uint_16 ;number of transparent palette color (tRNS) num_trans dw ? ;uint_16 ;number of transparent palette color (tRNS)
bit_depth db ? ;byte ;1, 2, 4, 8, or 16 bits/channel (from IHDR) bit_depth db ? ;byte ;1, 2, 4, 8, or 16 bits/channel (from IHDR)
color_type db ? ;byte ;see PNG_COLOR_TYPE_ below (from IHDR) color_type db ? ;byte ;see PNG_COLOR_TYPE_ below (from IHDR)
; The following three should have been named *_method not *_type ; The following three should have been named *_method not *_type
compression_type db ? ;byte ;must be PNG_COMPRESSION_TYPE_BASE (IHDR) compression_type db ? ;byte ;must be PNG_COMPRESSION_TYPE_BASE (IHDR)
filter_type db ? ;byte ;must be PNG_FILTER_TYPE_BASE (from IHDR) filter_type db ? ;byte ;must be PNG_FILTER_TYPE_BASE (from IHDR)
interlace_type db ? ;byte ;One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 interlace_type db ? ;byte ;One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7
; The following are set by png_set_IHDR, called from the application on ; The following are set by png_set_IHDR, called from the application on
; write, but the are never actually used by the write code. ; write, but the are never actually used by the write code.
channels db ? ;byte ;number of data channels per pixel (1, 2, 3, 4) channels db ? ;byte ;number of data channels per pixel (1, 2, 3, 4)
pixel_depth db ? ;byte ;number of bits per pixel pixel_depth db ? ;byte ;number of bits per pixel
spare_byte db ? ;byte ;to align the data, and for future use spare_byte db ? ;byte ;to align the data, and for future use
if PNG_READ_SUPPORTED eq 1 if PNG_READ_SUPPORTED eq 1
; This is never set during write ; This is never set during write
signature db 8 ;byte[8] ;magic bytes read by libpng from start of file signature db 8 ;byte[8] ;magic bytes read by libpng from start of file
end if end if
; The rest of the data is optional. If you are reading, check the ; The rest of the data is optional. If you are reading, check the
; valid field to see if the information in these are valid. If you ; valid field to see if the information in these are valid. If you
; are writing, set the valid field to those chunks you want written, ; are writing, set the valid field to those chunks you want written,
; and initialize the appropriate fields below. ; and initialize the appropriate fields below.
if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1) if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
; png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are ; png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
; defined. When COLORSPACE is switched on all the colorspace-defining ; defined. When COLORSPACE is switched on all the colorspace-defining
; chunks should be enabled, when GAMMA is switched on all the gamma-defining ; chunks should be enabled, when GAMMA is switched on all the gamma-defining
; chunks should be enabled. If this is not done it becomes possible to read ; chunks should be enabled. If this is not done it becomes possible to read
; inconsistent PNG files and assign a probably incorrect interpretation to ; inconsistent PNG files and assign a probably incorrect interpretation to
; the information. (In other words, by carefully choosing which chunks to ; the information. (In other words, by carefully choosing which chunks to
; recognize the system configuration can select an interpretation for PNG ; recognize the system configuration can select an interpretation for PNG
; files containing ambiguous data and this will result in inconsistent ; files containing ambiguous data and this will result in inconsistent
; behavior between different libpng builds!) ; behavior between different libpng builds!)
colorspace png_colorspace colorspace png_colorspace
end if end if
if PNG_iCCP_SUPPORTED eq 1 if PNG_iCCP_SUPPORTED eq 1
; iCCP chunk data. ; iCCP chunk data.
iccp_name dd ? ;charp ;profile name iccp_name dd ? ;charp ;profile name
iccp_profile dd ? ;bytep ;International Color Consortium profile data iccp_profile dd ? ;bytep ;International Color Consortium profile data
iccp_proflen dd ? ;uint_32 ;ICC profile data length iccp_proflen dd ? ;uint_32 ;ICC profile data length
end if end if
if PNG_TEXT_SUPPORTED eq 1 if PNG_TEXT_SUPPORTED eq 1
; The tEXt, and zTXt chunks contain human-readable textual data in ; The tEXt, and zTXt chunks contain human-readable textual data in
; uncompressed, compressed, and optionally compressed forms, respectively. ; uncompressed, compressed, and optionally compressed forms, respectively.
; The data in "text" is an array of pointers to uncompressed, ; The data in "text" is an array of pointers to uncompressed,
; null-terminated C strings. Each chunk has a keyword that describes the ; null-terminated C strings. Each chunk has a keyword that describes the
; textual data contained in that chunk. Keywords are not required to be ; textual data contained in that chunk. Keywords are not required to be
; unique, and the text string may be empty. Any number of text chunks may ; unique, and the text string may be empty. Any number of text chunks may
; be in an image. ; be in an image.
num_text dd ? ;int ;number of comments read or comments to write num_text dd ? ;int ;number of comments read or comments to write
max_text dd ? ;int ;current size of text array max_text dd ? ;int ;current size of text array
text dd ? ;png_textp ;array of comments read or comments to write text dd ? ;png_textp ;array of comments read or comments to write
end if ;TEXT end if ;TEXT
if PNG_tIME_SUPPORTED eq 1 if PNG_tIME_SUPPORTED eq 1
; The tIME chunk holds the last time the displayed image data was ; The tIME chunk holds the last time the displayed image data was
; modified. See the png_time struct for the contents of this struct. ; modified. See the png_time struct for the contents of this struct.
mod_time png_time mod_time png_time
end if end if
if PNG_sBIT_SUPPORTED eq 1 if PNG_sBIT_SUPPORTED eq 1
; The sBIT chunk specifies the number of significant high-order bits ; The sBIT chunk specifies the number of significant high-order bits
; in the pixel data. Values are in the range [1, bit_depth], and are ; in the pixel data. Values are in the range [1, bit_depth], and are
; only specified for the channels in the pixel data. The contents of ; only specified for the channels in the pixel data. The contents of
; the low-order bits is not specified. Data is valid if ; the low-order bits is not specified. Data is valid if
; (valid & PNG_INFO_sBIT) is non-zero. ; (valid & PNG_INFO_sBIT) is non-zero.
sig_bit png_color_8 ; significant bits in color channels sig_bit png_color_8 ; significant bits in color channels
end if end if
if (PNG_tRNS_SUPPORTED eq 1) | (PNG_READ_EXPAND_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) if (PNG_tRNS_SUPPORTED eq 1) | (PNG_READ_EXPAND_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
; The tRNS chunk supplies transparency data for paletted images and ; The tRNS chunk supplies transparency data for paletted images and
; other image types that don't need a full alpha channel. There are ; other image types that don't need a full alpha channel. There are
; "num_trans" transparency values for a paletted image, stored in the ; "num_trans" transparency values for a paletted image, stored in the
; same order as the palette colors, starting from index 0. Values ; same order as the palette colors, starting from index 0. Values
; for the data are in the range [0, 255], ranging from fully transparent ; for the data are in the range [0, 255], ranging from fully transparent
; to fully opaque, respectively. For non-paletted images, there is a ; to fully opaque, respectively. For non-paletted images, there is a
; single color specified that should be treated as fully transparent. ; single color specified that should be treated as fully transparent.
; Data is valid if (valid & PNG_INFO_tRNS) is non-zero. ; Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
trans_alpha dd ? ;bytep ; alpha values for paletted image trans_alpha dd ? ;bytep ; alpha values for paletted image
trans_color png_color_16 ;transparent color for non-palette image trans_color png_color_16 ;transparent color for non-palette image
end if end if
if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
; The bKGD chunk gives the suggested image background color if the ; The bKGD chunk gives the suggested image background color if the
; display program does not have its own background color and the image ; display program does not have its own background color and the image
; is needs to composited onto a background before display. The colors ; is needs to composited onto a background before display. The colors
; in "background" are normally in the same color space/depth as the ; in "background" are normally in the same color space/depth as the
; pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. ; pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
background png_color_16 background png_color_16
end if end if
if PNG_oFFs_SUPPORTED eq 1 if PNG_oFFs_SUPPORTED eq 1
; The oFFs chunk gives the offset in "offset_unit_type" units rightwards ; The oFFs chunk gives the offset in "offset_unit_type" units rightwards
; and downwards from the top-left corner of the display, page, or other ; and downwards from the top-left corner of the display, page, or other
; application-specific co-ordinate space. See the PNG_OFFSET_ defines ; application-specific co-ordinate space. See the PNG_OFFSET_ defines
; below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. ; below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
x_offset dd ? ;int_32 ;x offset on page x_offset dd ? ;int_32 ;x offset on page
y_offset dd ? ;int_32 ;y offset on page y_offset dd ? ;int_32 ;y offset on page
offset_unit_type db ? ;byte ;offset units type offset_unit_type db ? ;byte ;offset units type
end if end if
if PNG_pHYs_SUPPORTED eq 1 if PNG_pHYs_SUPPORTED eq 1
; The pHYs chunk gives the physical pixel density of the image for ; The pHYs chunk gives the physical pixel density of the image for
; display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ ; display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
; defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. ; defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
x_pixels_per_unit dd ? ;uint_32 ;horizontal pixel density x_pixels_per_unit dd ? ;uint_32 ;horizontal pixel density
y_pixels_per_unit dd ? ;uint_32 ;vertical pixel density y_pixels_per_unit dd ? ;uint_32 ;vertical pixel density
phys_unit_type db ? ;byte ;resolution type (see PNG_RESOLUTION_ below) phys_unit_type db ? ;byte ;resolution type (see PNG_RESOLUTION_ below)
end if end if
if PNG_hIST_SUPPORTED eq 1 if PNG_hIST_SUPPORTED eq 1
; The hIST chunk contains the relative frequency or importance of the ; The hIST chunk contains the relative frequency or importance of the
; various palette entries, so that a viewer can intelligently select a ; various palette entries, so that a viewer can intelligently select a
; reduced-color palette, if required. Data is an array of "num_palette" ; reduced-color palette, if required. Data is an array of "num_palette"
; values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) ; values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
; is non-zero. ; is non-zero.
hist dd ? ;uint_16p hist dd ? ;uint_16p
end if end if
if PNG_pCAL_SUPPORTED eq 1 if PNG_pCAL_SUPPORTED eq 1
; The pCAL chunk describes a transformation between the stored pixel ; The pCAL chunk describes a transformation between the stored pixel
; values and original physical data values used to create the image. ; values and original physical data values used to create the image.
; The integer range [0, 2^bit_depth - 1] maps to the floating-point ; The integer range [0, 2^bit_depth - 1] maps to the floating-point
; range given by [pcal_X0, pcal_X1], and are further transformed by a ; range given by [pcal_X0, pcal_X1], and are further transformed by a
; (possibly non-linear) transformation function given by "pcal_type" ; (possibly non-linear) transformation function given by "pcal_type"
; and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ ; and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
; defines below, and the PNG-Group's PNG extensions document for a ; defines below, and the PNG-Group's PNG extensions document for a
; complete description of the transformations and how they should be ; complete description of the transformations and how they should be
; implemented, and for a description of the ASCII parameter strings. ; implemented, and for a description of the ASCII parameter strings.
; Data values are valid if (valid & PNG_INFO_pCAL) non-zero. ; Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
pcal_purpose dd ? ;charp ;pCAL chunk description string pcal_purpose dd ? ;charp ;pCAL chunk description string
pcal_X0 dd ? ;int_32 ;minimum value pcal_X0 dd ? ;int_32 ;minimum value
pcal_X1 dd ? ;int_32 ;maximum value pcal_X1 dd ? ;int_32 ;maximum value
pcal_units dd ? ;charp ;Latin-1 string giving physical units pcal_units dd ? ;charp ;Latin-1 string giving physical units
pcal_params dd ? ;charpp ;ASCII strings containing parameter values pcal_params dd ? ;charpp ;ASCII strings containing parameter values
pcal_type db ? ;byte ;equation type (see PNG_EQUATION_ below) pcal_type db ? ;byte ;equation type (see PNG_EQUATION_ below)
pcal_nparams db ? ;byte ;number of parameters given in pcal_params pcal_nparams db ? ;byte ;number of parameters given in pcal_params
end if end if
; New members added in libpng-1.0.6 ; New members added in libpng-1.0.6
free_me dd ? ;uint_32 ;flags items libpng is responsible for freeing free_me dd ? ;uint_32 ;flags items libpng is responsible for freeing
if PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED eq 1 if PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED eq 1
; Storage for unknown chunks that the library doesn't recognize. ; Storage for unknown chunks that the library doesn't recognize.
unknown_chunks dd ? ;png_unknown_chunkp unknown_chunks dd ? ;png_unknown_chunkp
; The type of this field is limited by the type of ; The type of this field is limited by the type of
; png_struct::user_chunk_cache_max, else overflow can occur. ; png_struct::user_chunk_cache_max, else overflow can occur.
unknown_chunks_num dd ? ;int unknown_chunks_num dd ? ;int
end if end if
if PNG_sPLT_SUPPORTED eq 1 if PNG_sPLT_SUPPORTED eq 1
; Data on sPLT chunks (there may be more than one). ; Data on sPLT chunks (there may be more than one).
splt_palettes dd ? ;png_sPLT_tp splt_palettes dd ? ;png_sPLT_tp
splt_palettes_num dd ? ;int ;Match type returned by png_get API splt_palettes_num dd ? ;int ;Match type returned by png_get API
end if end if
if PNG_sCAL_SUPPORTED eq 1 if PNG_sCAL_SUPPORTED eq 1
; The sCAL chunk describes the actual physical dimensions of the ; The sCAL chunk describes the actual physical dimensions of the
; subject matter of the graphic. The chunk contains a unit specification ; subject matter of the graphic. The chunk contains a unit specification
; a byte value, and two ASCII strings representing floating-point ; a byte value, and two ASCII strings representing floating-point
; values. The values are width and height corresponsing to one pixel ; values. The values are width and height corresponsing to one pixel
; in the image. Data values are valid if (valid & PNG_INFO_sCAL) is ; in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
; non-zero. ; non-zero.
scal_unit db ? ;byte ;unit of physical scale scal_unit db ? ;byte ;unit of physical scale
scal_s_width dd ? ;charp ;string containing height scal_s_width dd ? ;charp ;string containing height
scal_s_height dd ? ;charp ;string containing width scal_s_height dd ? ;charp ;string containing width
end if end if
if PNG_INFO_IMAGE_SUPPORTED eq 1 if PNG_INFO_IMAGE_SUPPORTED eq 1
; Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) ; Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
; non-zero ; non-zero
; Data valid if (valid & PNG_INFO_IDAT) non-zero ; Data valid if (valid & PNG_INFO_IDAT) non-zero
row_pointers dd ? ;bytepp ;the image bits row_pointers dd ? ;bytepp ;the image bits
end if end if
ends ends

View File

@@ -1,209 +1,209 @@
; libpng 1.6.25 STANDARD API DEFINITION ; libpng 1.6.25 STANDARD API DEFINITION
; pnglibconf.inc - library build configuration ; pnglibconf.inc - library build configuration
; Libpng version 1.6.25 - September 1, 2016 ; Libpng version 1.6.25 - September 1, 2016
; Copyright (c) 1998-2015 Glenn Randers-Pehrson ; Copyright (c) 1998-2015 Glenn Randers-Pehrson
; This code is released under the libpng license. ; This code is released under the libpng license.
; For conditions of distribution and use, see the disclaimer ; For conditions of distribution and use, see the disclaimer
; and license in png.inc ; and license in png.inc
; pnglibconf.inc ; pnglibconf.inc
; Machine generated file: DO NOT EDIT ; Machine generated file: DO NOT EDIT
; Derived from: scripts/pnglibconf.dfa ; Derived from: scripts/pnglibconf.dfa
; options ; options
PNG_16BIT_SUPPORTED equ 1 PNG_16BIT_SUPPORTED equ 1
PNG_ALIGNED_MEMORY_SUPPORTED equ 1 PNG_ALIGNED_MEMORY_SUPPORTED equ 1
;/*#undef PNG_ARM_NEON_API_SUPPORTED*/ ;/*#undef PNG_ARM_NEON_API_SUPPORTED*/
;/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ ;/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
PNG_BENIGN_ERRORS_SUPPORTED equ 1 PNG_BENIGN_ERRORS_SUPPORTED equ 1
PNG_BENIGN_READ_ERRORS_SUPPORTED equ 1 PNG_BENIGN_READ_ERRORS_SUPPORTED equ 1
;/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ ;/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED equ 1 PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED equ 1
PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 1 PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 1
PNG_COLORSPACE_SUPPORTED equ 1 PNG_COLORSPACE_SUPPORTED equ 1
PNG_CONSOLE_IO_SUPPORTED equ 1 PNG_CONSOLE_IO_SUPPORTED equ 1
PNG_CONVERT_tIME_SUPPORTED equ 1 PNG_CONVERT_tIME_SUPPORTED equ 1
PNG_EASY_ACCESS_SUPPORTED equ 1 PNG_EASY_ACCESS_SUPPORTED equ 1
;/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ ;/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
PNG_ERROR_TEXT_SUPPORTED equ 1 PNG_ERROR_TEXT_SUPPORTED equ 1
PNG_FIXED_POINT_SUPPORTED equ 1 PNG_FIXED_POINT_SUPPORTED equ 1
PNG_FLOATING_ARITHMETIC_SUPPORTED equ 1 PNG_FLOATING_ARITHMETIC_SUPPORTED equ 1
PNG_FLOATING_POINT_SUPPORTED equ 1 PNG_FLOATING_POINT_SUPPORTED equ 1
PNG_FORMAT_AFIRST_SUPPORTED equ 1 PNG_FORMAT_AFIRST_SUPPORTED equ 1
PNG_FORMAT_BGR_SUPPORTED equ 1 PNG_FORMAT_BGR_SUPPORTED equ 1
PNG_GAMMA_SUPPORTED equ 1 PNG_GAMMA_SUPPORTED equ 1
PNG_GET_PALETTE_MAX_SUPPORTED equ 1 PNG_GET_PALETTE_MAX_SUPPORTED equ 1
PNG_HANDLE_AS_UNKNOWN_SUPPORTED equ 1 PNG_HANDLE_AS_UNKNOWN_SUPPORTED equ 1
PNG_INCH_CONVERSIONS_SUPPORTED equ 1 PNG_INCH_CONVERSIONS_SUPPORTED equ 1
PNG_INFO_IMAGE_SUPPORTED equ 1 PNG_INFO_IMAGE_SUPPORTED equ 1
PNG_IO_STATE_SUPPORTED equ 1 PNG_IO_STATE_SUPPORTED equ 1
PNG_MNG_FEATURES_SUPPORTED equ 0 PNG_MNG_FEATURES_SUPPORTED equ 0
PNG_POINTER_INDEXING_SUPPORTED equ 1 PNG_POINTER_INDEXING_SUPPORTED equ 1
PNG_PROGRESSIVE_READ_SUPPORTED equ 0 PNG_PROGRESSIVE_READ_SUPPORTED equ 0
PNG_READ_16BIT_SUPPORTED equ 0 PNG_READ_16BIT_SUPPORTED equ 0
PNG_READ_ALPHA_MODE_SUPPORTED equ 0 PNG_READ_ALPHA_MODE_SUPPORTED equ 0
PNG_READ_ANCILLARY_CHUNKS_SUPPORTED equ 0 PNG_READ_ANCILLARY_CHUNKS_SUPPORTED equ 0
PNG_READ_BACKGROUND_SUPPORTED equ 0 PNG_READ_BACKGROUND_SUPPORTED equ 0
PNG_READ_BGR_SUPPORTED equ 0 PNG_READ_BGR_SUPPORTED equ 0
PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 0 PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 0
PNG_READ_COMPOSITE_NODIV_SUPPORTED equ 0 PNG_READ_COMPOSITE_NODIV_SUPPORTED equ 0
PNG_READ_COMPRESSED_TEXT_SUPPORTED equ 0 PNG_READ_COMPRESSED_TEXT_SUPPORTED equ 0
PNG_READ_EXPAND_16_SUPPORTED equ 0 PNG_READ_EXPAND_16_SUPPORTED equ 0
PNG_READ_EXPAND_SUPPORTED equ 0 PNG_READ_EXPAND_SUPPORTED equ 0
PNG_READ_FILLER_SUPPORTED equ 0 PNG_READ_FILLER_SUPPORTED equ 0
PNG_READ_GAMMA_SUPPORTED equ 0 PNG_READ_GAMMA_SUPPORTED equ 0
PNG_READ_GET_PALETTE_MAX_SUPPORTED equ 0 PNG_READ_GET_PALETTE_MAX_SUPPORTED equ 0
PNG_READ_GRAY_TO_RGB_SUPPORTED equ 0 PNG_READ_GRAY_TO_RGB_SUPPORTED equ 0
PNG_READ_INTERLACING_SUPPORTED equ 0 PNG_READ_INTERLACING_SUPPORTED equ 0
PNG_READ_INT_FUNCTIONS_SUPPORTED equ 0 PNG_READ_INT_FUNCTIONS_SUPPORTED equ 0
PNG_READ_INVERT_ALPHA_SUPPORTED equ 0 PNG_READ_INVERT_ALPHA_SUPPORTED equ 0
PNG_READ_INVERT_SUPPORTED equ 0 PNG_READ_INVERT_SUPPORTED equ 0
PNG_READ_OPT_PLTE_SUPPORTED equ 0 PNG_READ_OPT_PLTE_SUPPORTED equ 0
PNG_READ_PACKSWAP_SUPPORTED equ 0 PNG_READ_PACKSWAP_SUPPORTED equ 0
PNG_READ_PACK_SUPPORTED equ 0 PNG_READ_PACK_SUPPORTED equ 0
PNG_READ_QUANTIZE_SUPPORTED equ 0 PNG_READ_QUANTIZE_SUPPORTED equ 0
PNG_READ_RGB_TO_GRAY_SUPPORTED equ 0 PNG_READ_RGB_TO_GRAY_SUPPORTED equ 0
PNG_READ_SCALE_16_TO_8_SUPPORTED equ 0 PNG_READ_SCALE_16_TO_8_SUPPORTED equ 0
PNG_READ_SHIFT_SUPPORTED equ 0 PNG_READ_SHIFT_SUPPORTED equ 0
PNG_READ_STRIP_16_TO_8_SUPPORTED equ 0 PNG_READ_STRIP_16_TO_8_SUPPORTED equ 0
PNG_READ_STRIP_ALPHA_SUPPORTED equ 0 PNG_READ_STRIP_ALPHA_SUPPORTED equ 0
PNG_READ_SUPPORTED equ 0 PNG_READ_SUPPORTED equ 0
PNG_READ_SWAP_ALPHA_SUPPORTED equ 0 PNG_READ_SWAP_ALPHA_SUPPORTED equ 0
PNG_READ_SWAP_SUPPORTED equ 0 PNG_READ_SWAP_SUPPORTED equ 0
PNG_READ_TEXT_SUPPORTED equ 0 PNG_READ_TEXT_SUPPORTED equ 0
PNG_READ_TRANSFORMS_SUPPORTED equ 0 PNG_READ_TRANSFORMS_SUPPORTED equ 0
PNG_READ_UNKNOWN_CHUNKS_SUPPORTED equ 0 PNG_READ_UNKNOWN_CHUNKS_SUPPORTED equ 0
PNG_READ_USER_CHUNKS_SUPPORTED equ 0 PNG_READ_USER_CHUNKS_SUPPORTED equ 0
PNG_READ_USER_TRANSFORM_SUPPORTED equ 0 PNG_READ_USER_TRANSFORM_SUPPORTED equ 0
PNG_READ_bKGD_SUPPORTED equ 0 PNG_READ_bKGD_SUPPORTED equ 0
PNG_READ_cHRM_SUPPORTED equ 0 PNG_READ_cHRM_SUPPORTED equ 0
PNG_READ_gAMA_SUPPORTED equ 0 PNG_READ_gAMA_SUPPORTED equ 0
PNG_READ_hIST_SUPPORTED equ 0 PNG_READ_hIST_SUPPORTED equ 0
PNG_READ_iCCP_SUPPORTED equ 0 PNG_READ_iCCP_SUPPORTED equ 0
PNG_READ_iTXt_SUPPORTED equ 0 PNG_READ_iTXt_SUPPORTED equ 0
PNG_READ_oFFs_SUPPORTED equ 0 PNG_READ_oFFs_SUPPORTED equ 0
PNG_READ_pCAL_SUPPORTED equ 0 PNG_READ_pCAL_SUPPORTED equ 0
PNG_READ_pHYs_SUPPORTED equ 0 PNG_READ_pHYs_SUPPORTED equ 0
PNG_READ_sBIT_SUPPORTED equ 0 PNG_READ_sBIT_SUPPORTED equ 0
PNG_READ_sCAL_SUPPORTED equ 0 PNG_READ_sCAL_SUPPORTED equ 0
PNG_READ_sPLT_SUPPORTED equ 0 PNG_READ_sPLT_SUPPORTED equ 0
PNG_READ_sRGB_SUPPORTED equ 0 PNG_READ_sRGB_SUPPORTED equ 0
PNG_READ_tEXt_SUPPORTED equ 0 PNG_READ_tEXt_SUPPORTED equ 0
PNG_READ_tIME_SUPPORTED equ 0 PNG_READ_tIME_SUPPORTED equ 0
PNG_READ_tRNS_SUPPORTED equ 0 PNG_READ_tRNS_SUPPORTED equ 0
PNG_READ_zTXt_SUPPORTED equ 0 PNG_READ_zTXt_SUPPORTED equ 0
PNG_SAVE_INT_32_SUPPORTED equ 1 PNG_SAVE_INT_32_SUPPORTED equ 1
PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED equ 1 PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED equ 1
PNG_SEQUENTIAL_READ_SUPPORTED equ 1 PNG_SEQUENTIAL_READ_SUPPORTED equ 1
PNG_SETJMP_SUPPORTED equ 0 ;1 ;setjmp.h заголовочный файл стандартной библиотеки языка Си PNG_SETJMP_SUPPORTED equ 0 ;1 ;setjmp.h заголовочный файл стандартной библиотеки языка Си
PNG_SET_OPTION_SUPPORTED equ 1 PNG_SET_OPTION_SUPPORTED equ 1
PNG_SET_UNKNOWN_CHUNKS_SUPPORTED equ 1 PNG_SET_UNKNOWN_CHUNKS_SUPPORTED equ 1
PNG_SET_USER_LIMITS_SUPPORTED equ 1 PNG_SET_USER_LIMITS_SUPPORTED equ 1
PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED equ 1 PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED equ 1
PNG_SIMPLIFIED_READ_BGR_SUPPORTED equ 1 PNG_SIMPLIFIED_READ_BGR_SUPPORTED equ 1
PNG_SIMPLIFIED_READ_SUPPORTED equ 1 PNG_SIMPLIFIED_READ_SUPPORTED equ 1
PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED equ 1 PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED equ 1
PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED equ 1 PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED equ 1
PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED equ 0 ;1 PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED equ 0 ;1
PNG_SIMPLIFIED_WRITE_SUPPORTED equ 1 PNG_SIMPLIFIED_WRITE_SUPPORTED equ 1
PNG_STDIO_SUPPORTED equ 1 PNG_STDIO_SUPPORTED equ 1
PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED equ 1 PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED equ 1
PNG_TEXT_SUPPORTED equ 0 PNG_TEXT_SUPPORTED equ 0
PNG_TIME_RFC1123_SUPPORTED equ 1 PNG_TIME_RFC1123_SUPPORTED equ 1
PNG_UNKNOWN_CHUNKS_SUPPORTED equ 1 PNG_UNKNOWN_CHUNKS_SUPPORTED equ 1
PNG_USER_CHUNKS_SUPPORTED equ 1 PNG_USER_CHUNKS_SUPPORTED equ 1
PNG_USER_LIMITS_SUPPORTED equ 1 PNG_USER_LIMITS_SUPPORTED equ 1
PNG_USER_MEM_SUPPORTED equ 1 PNG_USER_MEM_SUPPORTED equ 1
PNG_USER_TRANSFORM_INFO_SUPPORTED equ 1 PNG_USER_TRANSFORM_INFO_SUPPORTED equ 1
PNG_USER_TRANSFORM_PTR_SUPPORTED equ 1 PNG_USER_TRANSFORM_PTR_SUPPORTED equ 1
PNG_WARNINGS_SUPPORTED equ 0 PNG_WARNINGS_SUPPORTED equ 0
PNG_WRITE_16BIT_SUPPORTED equ 1 PNG_WRITE_16BIT_SUPPORTED equ 1
PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED equ 1 PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED equ 1
PNG_WRITE_BGR_SUPPORTED equ 1 PNG_WRITE_BGR_SUPPORTED equ 1
PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 1 PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 1
PNG_WRITE_COMPRESSED_TEXT_SUPPORTED equ 1 PNG_WRITE_COMPRESSED_TEXT_SUPPORTED equ 1
PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED equ 1 PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED equ 1
PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED equ 0 PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED equ 0
PNG_WRITE_FILLER_SUPPORTED equ 1 PNG_WRITE_FILLER_SUPPORTED equ 1
PNG_WRITE_FILTER_SUPPORTED equ 1 PNG_WRITE_FILTER_SUPPORTED equ 1
PNG_WRITE_FLUSH_SUPPORTED equ 1 PNG_WRITE_FLUSH_SUPPORTED equ 1
PNG_WRITE_GET_PALETTE_MAX_SUPPORTED equ 1 PNG_WRITE_GET_PALETTE_MAX_SUPPORTED equ 1
PNG_WRITE_INTERLACING_SUPPORTED equ 0 PNG_WRITE_INTERLACING_SUPPORTED equ 0
PNG_WRITE_INT_FUNCTIONS_SUPPORTED equ 1 PNG_WRITE_INT_FUNCTIONS_SUPPORTED equ 1
PNG_WRITE_INVERT_ALPHA_SUPPORTED equ 1 PNG_WRITE_INVERT_ALPHA_SUPPORTED equ 1
PNG_WRITE_INVERT_SUPPORTED equ 1 PNG_WRITE_INVERT_SUPPORTED equ 1
PNG_WRITE_OPTIMIZE_CMF_SUPPORTED equ 1 PNG_WRITE_OPTIMIZE_CMF_SUPPORTED equ 1
PNG_WRITE_PACKSWAP_SUPPORTED equ 1 PNG_WRITE_PACKSWAP_SUPPORTED equ 1
PNG_WRITE_PACK_SUPPORTED equ 1 PNG_WRITE_PACK_SUPPORTED equ 1
PNG_WRITE_SHIFT_SUPPORTED equ 1 PNG_WRITE_SHIFT_SUPPORTED equ 1
PNG_WRITE_SUPPORTED equ 1 PNG_WRITE_SUPPORTED equ 1
PNG_WRITE_SWAP_ALPHA_SUPPORTED equ 1 PNG_WRITE_SWAP_ALPHA_SUPPORTED equ 1
PNG_WRITE_SWAP_SUPPORTED equ 1 PNG_WRITE_SWAP_SUPPORTED equ 1
PNG_WRITE_TEXT_SUPPORTED equ 0 PNG_WRITE_TEXT_SUPPORTED equ 0
PNG_WRITE_TRANSFORMS_SUPPORTED equ 1 PNG_WRITE_TRANSFORMS_SUPPORTED equ 1
PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED equ 0 PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED equ 0
PNG_WRITE_USER_TRANSFORM_SUPPORTED equ 1 PNG_WRITE_USER_TRANSFORM_SUPPORTED equ 1
PNG_WRITE_WEIGHTED_FILTER_SUPPORTED equ 1 PNG_WRITE_WEIGHTED_FILTER_SUPPORTED equ 1
PNG_WRITE_bKGD_SUPPORTED equ 0 PNG_WRITE_bKGD_SUPPORTED equ 0
PNG_WRITE_cHRM_SUPPORTED equ 0 PNG_WRITE_cHRM_SUPPORTED equ 0
PNG_WRITE_gAMA_SUPPORTED equ 0 PNG_WRITE_gAMA_SUPPORTED equ 0
PNG_WRITE_hIST_SUPPORTED equ 0 PNG_WRITE_hIST_SUPPORTED equ 0
PNG_WRITE_iCCP_SUPPORTED equ 0 PNG_WRITE_iCCP_SUPPORTED equ 0
PNG_WRITE_iTXt_SUPPORTED equ 0 PNG_WRITE_iTXt_SUPPORTED equ 0
PNG_WRITE_oFFs_SUPPORTED equ 0 PNG_WRITE_oFFs_SUPPORTED equ 0
PNG_WRITE_pCAL_SUPPORTED equ 0 PNG_WRITE_pCAL_SUPPORTED equ 0
PNG_WRITE_pHYs_SUPPORTED equ 0 PNG_WRITE_pHYs_SUPPORTED equ 0
PNG_WRITE_sBIT_SUPPORTED equ 0 PNG_WRITE_sBIT_SUPPORTED equ 0
PNG_WRITE_sCAL_SUPPORTED equ 0 PNG_WRITE_sCAL_SUPPORTED equ 0
PNG_WRITE_sPLT_SUPPORTED equ 0 PNG_WRITE_sPLT_SUPPORTED equ 0
PNG_WRITE_sRGB_SUPPORTED equ 0 PNG_WRITE_sRGB_SUPPORTED equ 0
PNG_WRITE_tEXt_SUPPORTED equ 0 PNG_WRITE_tEXt_SUPPORTED equ 0
PNG_WRITE_tIME_SUPPORTED equ 0 PNG_WRITE_tIME_SUPPORTED equ 0
PNG_WRITE_tRNS_SUPPORTED equ 0 PNG_WRITE_tRNS_SUPPORTED equ 0
PNG_WRITE_zTXt_SUPPORTED equ 0 PNG_WRITE_zTXt_SUPPORTED equ 0
PNG_bKGD_SUPPORTED equ 0 PNG_bKGD_SUPPORTED equ 0
PNG_cHRM_SUPPORTED equ 0 PNG_cHRM_SUPPORTED equ 0
PNG_gAMA_SUPPORTED equ 0 PNG_gAMA_SUPPORTED equ 0
PNG_hIST_SUPPORTED equ 0 PNG_hIST_SUPPORTED equ 0
PNG_iCCP_SUPPORTED equ 0 PNG_iCCP_SUPPORTED equ 0
PNG_iTXt_SUPPORTED equ 0 PNG_iTXt_SUPPORTED equ 0
PNG_oFFs_SUPPORTED equ 0 PNG_oFFs_SUPPORTED equ 0
PNG_pCAL_SUPPORTED equ 0 PNG_pCAL_SUPPORTED equ 0
PNG_pHYs_SUPPORTED equ 0 PNG_pHYs_SUPPORTED equ 0
PNG_sBIT_SUPPORTED equ 0 PNG_sBIT_SUPPORTED equ 0
PNG_sCAL_SUPPORTED equ 0 PNG_sCAL_SUPPORTED equ 0
PNG_sPLT_SUPPORTED equ 0 PNG_sPLT_SUPPORTED equ 0
PNG_sRGB_SUPPORTED equ 0 PNG_sRGB_SUPPORTED equ 0
PNG_tEXt_SUPPORTED equ 0 PNG_tEXt_SUPPORTED equ 0
PNG_tIME_SUPPORTED equ 0 PNG_tIME_SUPPORTED equ 0
PNG_tRNS_SUPPORTED equ 0 PNG_tRNS_SUPPORTED equ 0
PNG_zTXt_SUPPORTED equ 0 PNG_zTXt_SUPPORTED equ 0
; end of options ; end of options
; settings ; settings
PNG_API_RULE equ 0 PNG_API_RULE equ 0
PNG_DEFAULT_READ_MACROS equ 1 PNG_DEFAULT_READ_MACROS equ 1
PNG_GAMMA_THRESHOLD_FIXED equ 5000 PNG_GAMMA_THRESHOLD_FIXED equ 5000
PNG_ZBUF_SIZE equ 8192 PNG_ZBUF_SIZE equ 8192
PNG_IDAT_READ_SIZE equ PNG_ZBUF_SIZE PNG_IDAT_READ_SIZE equ PNG_ZBUF_SIZE
PNG_INFLATE_BUF_SIZE equ 1024 PNG_INFLATE_BUF_SIZE equ 1024
PNG_MAX_GAMMA_8 equ 11 PNG_MAX_GAMMA_8 equ 11
PNG_QUANTIZE_BLUE_BITS equ 5 PNG_QUANTIZE_BLUE_BITS equ 5
PNG_QUANTIZE_GREEN_BITS equ 5 PNG_QUANTIZE_GREEN_BITS equ 5
PNG_QUANTIZE_RED_BITS equ 5 PNG_QUANTIZE_RED_BITS equ 5
PNG_TEXT_Z_DEFAULT_COMPRESSION equ (-1) PNG_TEXT_Z_DEFAULT_COMPRESSION equ (-1)
PNG_TEXT_Z_DEFAULT_STRATEGY equ 0 PNG_TEXT_Z_DEFAULT_STRATEGY equ 0
PNG_USER_CHUNK_CACHE_MAX equ 1000 PNG_USER_CHUNK_CACHE_MAX equ 1000
PNG_USER_CHUNK_MALLOC_MAX equ 8000000 PNG_USER_CHUNK_MALLOC_MAX equ 8000000
PNG_USER_HEIGHT_MAX equ 1000000 PNG_USER_HEIGHT_MAX equ 1000000
PNG_USER_WIDTH_MAX equ 1000000 PNG_USER_WIDTH_MAX equ 1000000
PNG_ZLIB_VERNUM equ 0 ;unknown PNG_ZLIB_VERNUM equ 0 ;unknown
PNG_Z_DEFAULT_COMPRESSION equ (-1) PNG_Z_DEFAULT_COMPRESSION equ (-1)
PNG_Z_DEFAULT_NOFILTER_STRATEGY equ 0 PNG_Z_DEFAULT_NOFILTER_STRATEGY equ 0
PNG_Z_DEFAULT_STRATEGY equ 1 PNG_Z_DEFAULT_STRATEGY equ 1
PNG_sCAL_PRECISION equ 5 PNG_sCAL_PRECISION equ 5
PNG_sRGB_PROFILE_CHECKS equ 2 PNG_sRGB_PROFILE_CHECKS equ 2
; end of settings ; end of settings

View File

@@ -1,303 +1,303 @@
; pngmem.asm - stub functions for memory allocation ; pngmem.asm - stub functions for memory allocation
; Last changed in libpng 1.6.24 [August 4, 2016%] ; Last changed in libpng 1.6.24 [August 4, 2016%]
; Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson ; Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) ; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) ; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
; This code is released under the libpng license. ; This code is released under the libpng license.
; For conditions of distribution and use, see the disclaimer ; For conditions of distribution and use, see the disclaimer
; and license in png.inc ; and license in png.inc
; This file provides a location for all memory allocation. Users who ; This file provides a location for all memory allocation. Users who
; need special memory handling are expected to supply replacement ; need special memory handling are expected to supply replacement
; functions for png_malloc() and png_free(), and to use ; functions for png_malloc() and png_free(), and to use
; png_create_read_struct_2() and png_create_write_struct_2() to ; png_create_read_struct_2() and png_create_write_struct_2() to
; identify the replacement functions. ; identify the replacement functions.
; Free a png_struct ; Free a png_struct
;void (png_structrp png_ptr) ;void (png_structrp png_ptr)
align 4 align 4
proc png_destroy_png_struct uses eax ecx edi esi, png_ptr:dword proc png_destroy_png_struct uses eax ecx edi esi, png_ptr:dword
locals locals
dummy_struct png_struct dummy_struct png_struct
endl endl
mov edi,[png_ptr] mov edi,[png_ptr]
cmp edi,0 cmp edi,0
je @f ;if (..!=0) je @f ;if (..!=0)
; png_free might call png_error and may certainly call ; png_free might call png_error and may certainly call
; png_get_mem_ptr, so fake a temporary png_struct to support this. ; png_get_mem_ptr, so fake a temporary png_struct to support this.
mov ecx,sizeof.png_struct mov ecx,sizeof.png_struct
mov esi,edi mov esi,edi
mov edi,ebp mov edi,ebp
sub edi,ecx sub edi,ecx
rep movsb ;dummy_struct = *png_ptr rep movsb ;dummy_struct = *png_ptr
mov edi,[png_ptr] mov edi,[png_ptr]
xor eax,eax xor eax,eax
mov ecx,sizeof.png_struct mov ecx,sizeof.png_struct
rep stosb ;memset(png_ptr, 0, (sizeof *png_ptr)) rep stosb ;memset(png_ptr, 0, (sizeof *png_ptr))
mov esi,ebp mov esi,ebp
sub esi,sizeof.png_struct sub esi,sizeof.png_struct
stdcall png_free, esi, [png_ptr] stdcall png_free, esi, [png_ptr]
if PNG_SETJMP_SUPPORTED eq 1 if PNG_SETJMP_SUPPORTED eq 1
; We may have a jmp_buf left to deallocate. ; We may have a jmp_buf left to deallocate.
stdcall png_free_jmpbuf, esi stdcall png_free_jmpbuf, esi
end if end if
@@: @@:
ret ret
endp endp
; Allocate memory. For reasonable files, size should never exceed ; Allocate memory. For reasonable files, size should never exceed
; 64K. However, zlib may allocate more than 64K if you don't tell ; 64K. However, zlib may allocate more than 64K if you don't tell
; it not to. See zconf.h and png.h for more information. zlib does ; it not to. See zconf.h and png.h for more information. zlib does
; need to allocate exactly 64K, so whatever you call here must ; need to allocate exactly 64K, so whatever you call here must
; have the ability to do that. ; have the ability to do that.
;voidp (const_structrp png_ptr, png_alloc_size_t size) ;voidp (const_structrp png_ptr, png_alloc_size_t size)
align 4 align 4
proc png_calloc uses ebx ecx edi, png_ptr:dword, size:dword proc png_calloc uses ebx ecx edi, png_ptr:dword, size:dword
stdcall png_malloc, [png_ptr], [size] stdcall png_malloc, [png_ptr], [size]
cmp eax,0 cmp eax,0
je @f ;if (..!=0) je @f ;if (..!=0)
mov ebx,eax mov ebx,eax
mov edi,eax mov edi,eax
mov ecx,[size] mov ecx,[size]
xor eax,eax xor eax,eax
rep stosb ;memset(ret, 0, size) rep stosb ;memset(ret, 0, size)
mov eax,ebx mov eax,ebx
@@: @@:
ret ret
endp endp
; png_malloc_base, an internal function added at libpng 1.6.0, does the work of ; png_malloc_base, an internal function added at libpng 1.6.0, does the work of
; allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED. ; allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED.
; Checking and error handling must happen outside this routine; it returns NULL ; Checking and error handling must happen outside this routine; it returns NULL
; if the allocation cannot be done (for any reason.) ; if the allocation cannot be done (for any reason.)
;voidp (const_structrp png_ptr, png_alloc_size_t size) ;voidp (const_structrp png_ptr, png_alloc_size_t size)
align 4 align 4
proc png_malloc_base uses ebx ecx, png_ptr:dword, size:dword proc png_malloc_base uses ebx ecx, png_ptr:dword, size:dword
; Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS ; Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS
; allocators have also been removed in 1.6.0, so any 16-bit system now has ; allocators have also been removed in 1.6.0, so any 16-bit system now has
; to implement a user memory handler. This checks to be sure it isn't ; to implement a user memory handler. This checks to be sure it isn't
; called with big numbers. ; called with big numbers.
; Some compilers complain that this is always true. However, it ; Some compilers complain that this is always true. However, it
; can be false when integer overflow happens. ; can be false when integer overflow happens.
cmp dword[size],0 cmp dword[size],0
jle .end0 jle .end0
cmp dword[size],PNG_SIZE_MAX cmp dword[size],PNG_SIZE_MAX
jg .end0 ; if (..>.. && ..<=..) jg .end0 ; if (..>.. && ..<=..)
if PNG_MAX_MALLOC_64K eq 1 if PNG_MAX_MALLOC_64K eq 1
cmp dword[size],65536 cmp dword[size],65536
jg .end0 jg .end0
end if end if
if PNG_USER_MEM_SUPPORTED eq 1 if PNG_USER_MEM_SUPPORTED eq 1
mov ebx,[png_ptr] mov ebx,[png_ptr]
cmp ebx,0 cmp ebx,0
je @f je @f
cmp dword[ebx+png_struct.malloc_fn],0 cmp dword[ebx+png_struct.malloc_fn],0
je @f ;if (..!=0 && ..!=0) je @f ;if (..!=0 && ..!=0)
stdcall [ebx+png_struct.malloc_fn], ebx, [size] stdcall [ebx+png_struct.malloc_fn], ebx, [size]
jmp .end_f jmp .end_f
@@: ;else @@: ;else
end if end if
;stdcall [mem.alloc], [size] ;stdcall [mem.alloc], [size]
mcall SF_SYS_MISC, SSF_MEM_ALLOC, [size] mcall SF_SYS_MISC, SSF_MEM_ALLOC, [size]
jmp .end_f ;checked for truncation above jmp .end_f ;checked for truncation above
.end0: ;else .end0: ;else
xor eax,eax xor eax,eax
.end_f: .end_f:
ret ret
endp endp
; This is really here only to work round a spurious warning in GCC 4.6 and 4.7 ; This is really here only to work round a spurious warning in GCC 4.6 and 4.7
; that arises because of the checks in png_realloc_array that are repeated in ; that arises because of the checks in png_realloc_array that are repeated in
; png_malloc_array. ; png_malloc_array.
;voidp (const_structrp png_ptr, int nelements, size_t element_size) ;voidp (const_structrp png_ptr, int nelements, size_t element_size)
align 4 align 4
proc png_malloc_array_checked, png_ptr:dword, nelements:dword, element_size:dword proc png_malloc_array_checked, png_ptr:dword, nelements:dword, element_size:dword
; png_alloc_size_t req = nelements; /* known to be > 0 */ ; png_alloc_size_t req = nelements; /* known to be > 0 */
; if (req <= PNG_SIZE_MAX/element_size) ; if (req <= PNG_SIZE_MAX/element_size)
; return png_malloc_base(png_ptr, req * element_size); ; return png_malloc_base(png_ptr, req * element_size);
; The failure case when the request is too large ; The failure case when the request is too large
xor eax,eax xor eax,eax
.end_f: .end_f:
ret ret
endp endp
;voidp (const_structrp png_ptr, int nelements, size_t element_size) ;voidp (const_structrp png_ptr, int nelements, size_t element_size)
align 4 align 4
proc png_malloc_array, png_ptr:dword, nelements:dword, element_size:dword proc png_malloc_array, png_ptr:dword, nelements:dword, element_size:dword
; if (nelements <= 0 || element_size == 0) ; if (nelements <= 0 || element_size == 0)
; png_error(png_ptr, "internal error: array alloc"); ; png_error(png_ptr, "internal error: array alloc");
stdcall png_malloc_array_checked, [png_ptr], [nelements], [element_size] stdcall png_malloc_array_checked, [png_ptr], [nelements], [element_size]
ret ret
endp endp
;voidp (const_structrp png_ptr, const_voidp old_array, ;voidp (const_structrp png_ptr, const_voidp old_array,
; int old_elements, int add_elements, size_t element_size) ; int old_elements, int add_elements, size_t element_size)
align 4 align 4
proc png_realloc_array, png_ptr:dword, old_array:dword, old_elements:dword, add_elements:dword, element_size:dword proc png_realloc_array, png_ptr:dword, old_array:dword, old_elements:dword, add_elements:dword, element_size:dword
; These are internal errors: ; These are internal errors:
; if (add_elements <= 0 || element_size == 0 || old_elements < 0 || ; if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
; (old_array == NULL && old_elements > 0)) ; (old_array == NULL && old_elements > 0))
; png_error(png_ptr, "internal error: array realloc"); ; png_error(png_ptr, "internal error: array realloc");
; Check for overflow on the elements count (so the caller does not have to ; Check for overflow on the elements count (so the caller does not have to
; check.) ; check.)
; if (add_elements <= INT_MAX - old_elements) ; if (add_elements <= INT_MAX - old_elements)
; { ; {
; voidp new_array = png_malloc_array_checked(png_ptr, ; voidp new_array = png_malloc_array_checked(png_ptr,
; old_elements+add_elements, element_size); ; old_elements+add_elements, element_size);
; ;
; if (new_array != NULL) ; if (new_array != NULL)
; { ; {
; Because png_malloc_array worked the size calculations below cannot ; Because png_malloc_array worked the size calculations below cannot
; overflow. ; overflow.
; if (old_elements > 0) ; if (old_elements > 0)
; memcpy(new_array, old_array, element_size*(unsigned)old_elements); ; memcpy(new_array, old_array, element_size*(unsigned)old_elements);
; ;
; memset((char*)new_array + element_size*(unsigned)old_elements, 0, ; memset((char*)new_array + element_size*(unsigned)old_elements, 0,
; element_size*(unsigned)add_elements); ; element_size*(unsigned)add_elements);
; ;
; return new_array; ; return new_array;
; } ; }
; } ; }
xor eax,eax ;error xor eax,eax ;error
.end_f: .end_f:
ret ret
endp endp
; Various functions that have different error handling are derived from this. ; Various functions that have different error handling are derived from this.
; png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate ; png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
; function png_malloc_default is also provided. ; function png_malloc_default is also provided.
;voidp (const_structrp png_ptr, png_alloc_size_t size) ;voidp (const_structrp png_ptr, png_alloc_size_t size)
align 4 align 4
proc png_malloc uses edi, png_ptr:dword, size:dword proc png_malloc uses edi, png_ptr:dword, size:dword
xor eax,eax xor eax,eax
mov edi,[png_ptr] mov edi,[png_ptr]
cmp edi,0 cmp edi,0
je @f ;if (..==0) return 0 je @f ;if (..==0) return 0
stdcall png_malloc_base, edi, [size] stdcall png_malloc_base, edi, [size]
cmp eax,0 cmp eax,0
jne @f ;if (..==0) jne @f ;if (..==0)
png_error edi, 'Out of memory' ;'m' means png_malloc png_error edi, 'Out of memory' ;'m' means png_malloc
@@: @@:
ret ret
endp endp
;voidp (const_structrp png_ptr, png_alloc_size_t size) ;voidp (const_structrp png_ptr, png_alloc_size_t size)
align 4 align 4
proc png_malloc_default uses edi, png_ptr:dword, size:dword proc png_malloc_default uses edi, png_ptr:dword, size:dword
xor eax,eax xor eax,eax
mov edi,[png_ptr] mov edi,[png_ptr]
cmp edi,0 cmp edi,0
je @f ;if (..==0) return 0 je @f ;if (..==0) return 0
; Passing 'NULL' here bypasses the application provided memory handler. ; Passing 'NULL' here bypasses the application provided memory handler.
stdcall png_malloc_base, 0, [size] ;0 - use malloc stdcall png_malloc_base, 0, [size] ;0 - use malloc
cmp eax,0 cmp eax,0
jne @f ;if (..==0) jne @f ;if (..==0)
png_error edi, 'Out of Memory' ;'M' means png_malloc_default png_error edi, 'Out of Memory' ;'M' means png_malloc_default
@@: @@:
ret ret
endp endp
; This function was added at libpng version 1.2.3. The png_malloc_warn() ; This function was added at libpng version 1.2.3. The png_malloc_warn()
; function will issue a png_warning and return NULL instead of issuing a ; function will issue a png_warning and return NULL instead of issuing a
; png_error, if it fails to allocate the requested memory. ; png_error, if it fails to allocate the requested memory.
;voidp (const_structrp png_ptr, png_alloc_size_t size) ;voidp (const_structrp png_ptr, png_alloc_size_t size)
align 4 align 4
proc png_malloc_warn uses edi, png_ptr:dword, size:dword proc png_malloc_warn uses edi, png_ptr:dword, size:dword
mov edi,[png_ptr] mov edi,[png_ptr]
cmp edi,0 cmp edi,0
je .end0 ;if (..!=0) je .end0 ;if (..!=0)
stdcall png_malloc_base, edi, [size] stdcall png_malloc_base, edi, [size]
cmp eax,0 cmp eax,0
jne .end_f ;if (..!=0) return ret jne .end_f ;if (..!=0) return ret
png_warning edi, 'Out of memory' png_warning edi, 'Out of memory'
.end0: .end0:
xor eax,eax xor eax,eax
.end_f: .end_f:
ret ret
endp endp
; Free a pointer allocated by png_malloc(). If ptr is NULL, return ; Free a pointer allocated by png_malloc(). If ptr is NULL, return
; without taking any action. ; without taking any action.
;void (const_structrp png_ptr, voidp ptr) ;void (const_structrp png_ptr, voidp ptr)
align 4 align 4
proc png_free uses eax ebx ecx, png_ptr:dword, p2ptr:dword proc png_free uses eax ebx ecx, png_ptr:dword, p2ptr:dword
mov ebx,[png_ptr] mov ebx,[png_ptr]
cmp ebx,0 cmp ebx,0
je .end_f je .end_f
mov ecx,[p2ptr] mov ecx,[p2ptr]
cmp ecx,0 cmp ecx,0
je .end_f ;if (..==0 || ..==0) return je .end_f ;if (..==0 || ..==0) return
if PNG_USER_MEM_SUPPORTED eq 1 if PNG_USER_MEM_SUPPORTED eq 1
cmp dword[ebx+png_struct.free_fn],0 cmp dword[ebx+png_struct.free_fn],0
je @f ;if (..!=0) je @f ;if (..!=0)
stdcall dword[ebx+png_struct.free_fn], ebx, [p2ptr] stdcall dword[ebx+png_struct.free_fn], ebx, [p2ptr]
jmp .end_f jmp .end_f
@@: ;else @@: ;else
end if end if
mcall SF_SYS_MISC, SSF_MEM_FREE, [p2ptr] mcall SF_SYS_MISC, SSF_MEM_FREE, [p2ptr]
.end_f: .end_f:
ret ret
endp endp
; This function is called when the application wants to use another method ; This function is called when the application wants to use another method
; of allocating and freeing memory. ; of allocating and freeing memory.
;void (png_structrp png_ptr, voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) ;void (png_structrp png_ptr, voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
align 4 align 4
proc png_set_mem_fn uses eax edi, png_ptr:dword, mem_ptr:dword, malloc_fn:dword, free_fn:dword proc png_set_mem_fn uses eax edi, png_ptr:dword, mem_ptr:dword, malloc_fn:dword, free_fn:dword
mov edi,[png_ptr] mov edi,[png_ptr]
cmp edi,0 cmp edi,0
je @f ;if (..!=0) je @f ;if (..!=0)
mov eax,[mem_ptr] mov eax,[mem_ptr]
mov [edi+png_struct.mem_ptr],eax mov [edi+png_struct.mem_ptr],eax
mov eax,[malloc_fn] mov eax,[malloc_fn]
mov [edi+png_struct.malloc_fn],eax mov [edi+png_struct.malloc_fn],eax
mov eax,[free_fn] mov eax,[free_fn]
mov [edi+png_struct.free_fn],eax mov [edi+png_struct.free_fn],eax
@@: @@:
ret ret
endp endp
; This function returns a pointer to the mem_ptr associated with the user ; This function returns a pointer to the mem_ptr associated with the user
; functions. The application should free any memory associated with this ; functions. The application should free any memory associated with this
; pointer before png_write_destroy and png_read_destroy are called. ; pointer before png_write_destroy and png_read_destroy are called.
;voidp (const_structrp png_ptr) ;voidp (const_structrp png_ptr)
align 4 align 4
proc png_get_mem_ptr uses edi, png_ptr:dword proc png_get_mem_ptr uses edi, png_ptr:dword
xor eax,eax xor eax,eax
mov edi,[png_ptr] mov edi,[png_ptr]
cmp edi,0 cmp edi,0
je @f ;if (..==0) return 0 je @f ;if (..==0) return 0
mov eax,[edi+png_struct.mem_ptr] mov eax,[edi+png_struct.mem_ptr]
@@: @@:
ret ret
endp endp

View File

@@ -1,306 +1,306 @@
; ;
; Options ; Options
; ;
PNG_RELEASE_BUILD equ 1 PNG_RELEASE_BUILD equ 1
;--- ;---
; Various modes of operation. Note that after an init, mode is set to ; Various modes of operation. Note that after an init, mode is set to
; zero automatically when the structure is created. Three of these ; zero automatically when the structure is created. Three of these
; are defined in png.inc because they need to be visible to applications ; are defined in png.inc because they need to be visible to applications
; that call png_set_unknown_chunk(). ; that call png_set_unknown_chunk().
;PNG_HAVE_IHDR 0x01 (defined in png.inc) ;PNG_HAVE_IHDR 0x01 (defined in png.inc)
;PNG_HAVE_PLTE 0x02 (defined in png.inc) ;PNG_HAVE_PLTE 0x02 (defined in png.inc)
PNG_HAVE_IDAT equ 0x04 PNG_HAVE_IDAT equ 0x04
;PNG_AFTER_IDAT 0x08 (defined in png.inc) ;PNG_AFTER_IDAT 0x08 (defined in png.inc)
PNG_HAVE_IEND equ 0x10 PNG_HAVE_IEND equ 0x10
;0x20 (unused) ;0x20 (unused)
;0x40 (unused) ;0x40 (unused)
;0x80 (unused) ;0x80 (unused)
PNG_HAVE_CHUNK_HEADER equ 0x100 PNG_HAVE_CHUNK_HEADER equ 0x100
PNG_WROTE_tIME equ 0x200 PNG_WROTE_tIME equ 0x200
PNG_WROTE_INFO_BEFORE_PLTE equ 0x400 PNG_WROTE_INFO_BEFORE_PLTE equ 0x400
PNG_BACKGROUND_IS_GRAY equ 0x800 PNG_BACKGROUND_IS_GRAY equ 0x800
PNG_HAVE_PNG_SIGNATURE equ 0x1000 PNG_HAVE_PNG_SIGNATURE equ 0x1000
PNG_HAVE_CHUNK_AFTER_IDAT equ 0x2000 ;Have another chunk after IDAT PNG_HAVE_CHUNK_AFTER_IDAT equ 0x2000 ;Have another chunk after IDAT
;0x4000 (unused) ;0x4000 (unused)
PNG_IS_READ_STRUCT equ 0x8000 ;Else is a write struct PNG_IS_READ_STRUCT equ 0x8000 ;Else is a write struct
; Flags for the transformations the PNG library does on the image data ; Flags for the transformations the PNG library does on the image data
PNG_BGR equ 0x0001 PNG_BGR equ 0x0001
PNG_INTERLACE equ 0x0002 PNG_INTERLACE equ 0x0002
PNG_PACK equ 0x0004 PNG_PACK equ 0x0004
PNG_SHIFT equ 0x0008 PNG_SHIFT equ 0x0008
PNG_SWAP_BYTES equ 0x0010 PNG_SWAP_BYTES equ 0x0010
PNG_INVERT_MONO equ 0x0020 PNG_INVERT_MONO equ 0x0020
PNG_QUANTIZE equ 0x0040 PNG_QUANTIZE equ 0x0040
PNG_COMPOSE equ 0x0080 ;Was PNG_BACKGROUND PNG_COMPOSE equ 0x0080 ;Was PNG_BACKGROUND
PNG_BACKGROUND_EXPAND equ 0x0100 PNG_BACKGROUND_EXPAND equ 0x0100
PNG_EXPAND_16 equ 0x0200 ;Added to libpng 1.5.2 PNG_EXPAND_16 equ 0x0200 ;Added to libpng 1.5.2
PNG_16_TO_8 equ 0x0400 ;Becomes 'chop' in 1.5.4 PNG_16_TO_8 equ 0x0400 ;Becomes 'chop' in 1.5.4
PNG_RGBA equ 0x0800 PNG_RGBA equ 0x0800
PNG_EXPAND equ 0x1000 PNG_EXPAND equ 0x1000
PNG_GAMMA equ 0x2000 PNG_GAMMA equ 0x2000
PNG_GRAY_TO_RGB equ 0x4000 PNG_GRAY_TO_RGB equ 0x4000
PNG_FILLER equ 0x8000 PNG_FILLER equ 0x8000
PNG_PACKSWAP equ 0x10000 PNG_PACKSWAP equ 0x10000
PNG_SWAP_ALPHA equ 0x20000 PNG_SWAP_ALPHA equ 0x20000
PNG_STRIP_ALPHA equ 0x40000 PNG_STRIP_ALPHA equ 0x40000
PNG_INVERT_ALPHA equ 0x80000 PNG_INVERT_ALPHA equ 0x80000
PNG_USER_TRANSFORM equ 0x100000 PNG_USER_TRANSFORM equ 0x100000
PNG_RGB_TO_GRAY_ERR equ 0x200000 PNG_RGB_TO_GRAY_ERR equ 0x200000
PNG_RGB_TO_GRAY_WARN equ 0x400000 PNG_RGB_TO_GRAY_WARN equ 0x400000
PNG_RGB_TO_GRAY equ 0x600000 ;two bits, RGB_TO_GRAY_ERR|WARN PNG_RGB_TO_GRAY equ 0x600000 ;two bits, RGB_TO_GRAY_ERR|WARN
PNG_ENCODE_ALPHA equ 0x800000 ;Added to libpng-1.5.4 PNG_ENCODE_ALPHA equ 0x800000 ;Added to libpng-1.5.4
PNG_ADD_ALPHA equ 0x1000000 ;Added to libpng-1.2.7 PNG_ADD_ALPHA equ 0x1000000 ;Added to libpng-1.2.7
PNG_EXPAND_tRNS equ 0x2000000 ;Added to libpng-1.2.9 PNG_EXPAND_tRNS equ 0x2000000 ;Added to libpng-1.2.9
PNG_SCALE_16_TO_8 equ 0x4000000 ;Added to libpng-1.5.4 PNG_SCALE_16_TO_8 equ 0x4000000 ;Added to libpng-1.5.4
;0x8000000 unused ;0x8000000 unused
;0x10000000 unused ;0x10000000 unused
;0x20000000 unused ;0x20000000 unused
;0x40000000 unused ;0x40000000 unused
; Flags for png_create_struct ; Flags for png_create_struct
PNG_STRUCT_PNG equ 0x0001 PNG_STRUCT_PNG equ 0x0001
PNG_STRUCT_INFO equ 0x0002 PNG_STRUCT_INFO equ 0x0002
; Flags for the png_ptr->flags rather than declaring a byte for each one ; Flags for the png_ptr->flags rather than declaring a byte for each one
PNG_FLAG_ZLIB_CUSTOM_STRATEGY equ 0x0001 PNG_FLAG_ZLIB_CUSTOM_STRATEGY equ 0x0001
PNG_FLAG_ZSTREAM_INITIALIZED equ 0x0002 ;Added to libpng-1.6.0 PNG_FLAG_ZSTREAM_INITIALIZED equ 0x0002 ;Added to libpng-1.6.0
;0x0004 unused ;0x0004 unused
PNG_FLAG_ZSTREAM_ENDED equ 0x0008 ;Added to libpng-1.6.0 PNG_FLAG_ZSTREAM_ENDED equ 0x0008 ;Added to libpng-1.6.0
;0x0010 unused ;0x0010 unused
;0x0020 unused ;0x0020 unused
PNG_FLAG_ROW_INIT equ 0x0040 PNG_FLAG_ROW_INIT equ 0x0040
PNG_FLAG_FILLER_AFTER equ 0x0080 PNG_FLAG_FILLER_AFTER equ 0x0080
PNG_FLAG_CRC_ANCILLARY_USE equ 0x0100 PNG_FLAG_CRC_ANCILLARY_USE equ 0x0100
PNG_FLAG_CRC_ANCILLARY_NOWARN equ 0x0200 PNG_FLAG_CRC_ANCILLARY_NOWARN equ 0x0200
PNG_FLAG_CRC_CRITICAL_USE equ 0x0400 PNG_FLAG_CRC_CRITICAL_USE equ 0x0400
PNG_FLAG_CRC_CRITICAL_IGNORE equ 0x0800 PNG_FLAG_CRC_CRITICAL_IGNORE equ 0x0800
PNG_FLAG_ASSUME_sRGB equ 0x1000 ;Added to libpng-1.5.4 PNG_FLAG_ASSUME_sRGB equ 0x1000 ;Added to libpng-1.5.4
PNG_FLAG_OPTIMIZE_ALPHA equ 0x2000 ;Added to libpng-1.5.4 PNG_FLAG_OPTIMIZE_ALPHA equ 0x2000 ;Added to libpng-1.5.4
PNG_FLAG_DETECT_UNINITIALIZED equ 0x4000 ;Added to libpng-1.5.4 PNG_FLAG_DETECT_UNINITIALIZED equ 0x4000 ;Added to libpng-1.5.4
;PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000 ;PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000
;PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000 ;PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000
PNG_FLAG_LIBRARY_MISMATCH equ 0x20000 PNG_FLAG_LIBRARY_MISMATCH equ 0x20000
PNG_FLAG_STRIP_ERROR_NUMBERS equ 0x40000 PNG_FLAG_STRIP_ERROR_NUMBERS equ 0x40000
PNG_FLAG_STRIP_ERROR_TEXT equ 0x80000 PNG_FLAG_STRIP_ERROR_TEXT equ 0x80000
PNG_FLAG_BENIGN_ERRORS_WARN equ 0x100000 ;Added to libpng-1.4.0 PNG_FLAG_BENIGN_ERRORS_WARN equ 0x100000 ;Added to libpng-1.4.0
PNG_FLAG_APP_WARNINGS_WARN equ 0x200000 ;Added to libpng-1.6.0 PNG_FLAG_APP_WARNINGS_WARN equ 0x200000 ;Added to libpng-1.6.0
PNG_FLAG_APP_ERRORS_WARN equ 0x400000 ;Added to libpng-1.6.0 PNG_FLAG_APP_ERRORS_WARN equ 0x400000 ;Added to libpng-1.6.0
; Gamma values (new at libpng-1.5.4): ; Gamma values (new at libpng-1.5.4):
PNG_GAMMA_MAC_OLD equ 151724 ;Assume '1.8' is really 2.2/1.45! PNG_GAMMA_MAC_OLD equ 151724 ;Assume '1.8' is really 2.2/1.45!
PNG_GAMMA_MAC_INVERSE equ 65909 PNG_GAMMA_MAC_INVERSE equ 65909
PNG_GAMMA_sRGB_INVERSE equ 45455 PNG_GAMMA_sRGB_INVERSE equ 45455
macro PNG_ROWBYTES pixel_bits, width macro PNG_ROWBYTES pixel_bits, width
{ {
local .end0 local .end0
if pixel_bits eq eax if pixel_bits eq eax
else else
mov eax,pixel_bits mov eax,pixel_bits
end if end if
cmp eax,8 cmp eax,8
jge .end0 jge .end0
add eax,7 add eax,7
.end0: .end0:
shr eax,3 shr eax,3
imul eax,width imul eax,width
} }
; In 1.7.0 the definitions will be made public in png.inc to avoid having to ; In 1.7.0 the definitions will be made public in png.inc to avoid having to
; duplicate the same definitions in application code. ; duplicate the same definitions in application code.
png_IDAT equ 'IDAT' png_IDAT equ 'IDAT'
png_IEND equ 'IEND' png_IEND equ 'IEND'
png_IHDR equ 'IHDR' png_IHDR equ 'IHDR'
png_PLTE equ 'PLTE' png_PLTE equ 'PLTE'
png_bKGD equ 'bKGD' png_bKGD equ 'bKGD'
png_cHRM equ 'cHRM' png_cHRM equ 'cHRM'
png_fRAc equ 'fRAc' ;registered, not defined png_fRAc equ 'fRAc' ;registered, not defined
png_gAMA equ 'gAMA' png_gAMA equ 'gAMA'
png_gIFg equ 'gIFg' png_gIFg equ 'gIFg'
png_gIFt equ 'gIFt' ;deprecated png_gIFt equ 'gIFt' ;deprecated
png_gIFx equ 'gIFx' png_gIFx equ 'gIFx'
png_hIST equ 'hIST' png_hIST equ 'hIST'
png_iCCP equ 'iCCP' png_iCCP equ 'iCCP'
png_iTXt equ 'iTXt' png_iTXt equ 'iTXt'
png_oFFs equ 'oFFs' png_oFFs equ 'oFFs'
png_pCAL equ 'pCAL' png_pCAL equ 'pCAL'
png_pHYs equ 'pHYs' png_pHYs equ 'pHYs'
png_sBIT equ 'sBIT' png_sBIT equ 'sBIT'
png_sCAL equ 'sCAL' png_sCAL equ 'sCAL'
png_sPLT equ 'sPLT' png_sPLT equ 'sPLT'
png_sRGB equ 'sRGB' png_sRGB equ 'sRGB'
png_sTER equ 'sTER' png_sTER equ 'sTER'
png_tEXt equ 'tEXt' png_tEXt equ 'tEXt'
png_tIME equ 'tIME' png_tIME equ 'tIME'
png_tRNS equ 'tRNS' png_tRNS equ 'tRNS'
png_zTXt equ 'zTXt' png_zTXt equ 'zTXt'
;Test on flag values as defined in the spec (section 5.4): ;Test on flag values as defined in the spec (section 5.4):
macro PNG_CHUNK_ANCILLARY c macro PNG_CHUNK_ANCILLARY c
{ {
mov eax,c mov eax,c
shr eax,29 shr eax,29
and eax,1 and eax,1
} }
macro PNG_CHUNK_CRITICAL c macro PNG_CHUNK_CRITICAL c
{ {
PNG_CHUNK_ANCILLARY c PNG_CHUNK_ANCILLARY c
xor eax,1 xor eax,1
} }
macro PNG_CHUNK_PRIVATE c macro PNG_CHUNK_PRIVATE c
{ {
mov eax,c mov eax,c
shr eax,21 shr eax,21
and eax,1 and eax,1
} }
macro PNG_CHUNK_RESERVED c macro PNG_CHUNK_RESERVED c
{ {
mov eax,c mov eax,c
shr eax,13 shr eax,13
and eax,1 and eax,1
} }
macro PNG_CHUNK_SAFE_TO_COPY c macro PNG_CHUNK_SAFE_TO_COPY c
{ {
mov eax,c mov eax,c
shr eax,5 shr eax,5
and eax,1 and eax,1
} }
PNG_FLAG_CRC_ANCILLARY_MASK equ (PNG_FLAG_CRC_ANCILLARY_USE or PNG_FLAG_CRC_ANCILLARY_NOWARN) PNG_FLAG_CRC_ANCILLARY_MASK equ (PNG_FLAG_CRC_ANCILLARY_USE or PNG_FLAG_CRC_ANCILLARY_NOWARN)
PNG_FLAG_CRC_CRITICAL_MASK equ (PNG_FLAG_CRC_CRITICAL_USE or PNG_FLAG_CRC_CRITICAL_IGNORE) PNG_FLAG_CRC_CRITICAL_MASK equ (PNG_FLAG_CRC_CRITICAL_USE or PNG_FLAG_CRC_CRITICAL_IGNORE)
PNG_FLAG_CRC_MASK equ (PNG_FLAG_CRC_ANCILLARY_MASK or PNG_FLAG_CRC_CRITICAL_MASK) PNG_FLAG_CRC_MASK equ (PNG_FLAG_CRC_ANCILLARY_MASK or PNG_FLAG_CRC_CRITICAL_MASK)
macro PNG_sRGB_FROM_LINEAR linear macro PNG_sRGB_FROM_LINEAR linear
{ {
mov eax,linear mov eax,linear
shr eax,15 shr eax,15
shl eax,1 shl eax,1
add eax,png_sRGB_base add eax,png_sRGB_base
movzx eax,word[eax] movzx eax,word[eax]
push ebx ecx push ebx ecx
mov ebx,linear mov ebx,linear
shr ebx,15 shr ebx,15
add ebx,png_sRGB_delta add ebx,png_sRGB_delta
mov ecx,linear mov ecx,linear
and ecx,0x7fff and ecx,0x7fff
imul ecx,ebx imul ecx,ebx
shr ecx,12 shr ecx,12
add eax,ecx add eax,ecx
pop ecx ebx pop ecx ebx
shr eax,8 shr eax,8
;;;and eax,0xff ;;;and eax,0xff
} }
; Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB ; Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
; encoded value with maximum error 0.646365. Note that the input is not a ; encoded value with maximum error 0.646365. Note that the input is not a
; 16-bit value; it has been multiplied by 255! ; 16-bit value; it has been multiplied by 255!
PNG_UNEXPECTED_ZLIB_RETURN equ (-7) PNG_UNEXPECTED_ZLIB_RETURN equ (-7)
;... ;...
; Suggested size for a number buffer (enough for 64 bits and a sign!) ; Suggested size for a number buffer (enough for 64 bits and a sign!)
PNG_NUMBER_BUFFER_SIZE equ 24 PNG_NUMBER_BUFFER_SIZE equ 24
; These are the integer formats currently supported, the name is formed from ; These are the integer formats currently supported, the name is formed from
; the standard printf(3) format string. ; the standard printf(3) format string.
PNG_NUMBER_FORMAT_u equ 1 ;chose unsigned API! PNG_NUMBER_FORMAT_u equ 1 ;chose unsigned API!
PNG_NUMBER_FORMAT_02u equ 2 PNG_NUMBER_FORMAT_02u equ 2
PNG_NUMBER_FORMAT_d equ 1 ;chose signed API! PNG_NUMBER_FORMAT_d equ 1 ;chose signed API!
PNG_NUMBER_FORMAT_02d equ 2 PNG_NUMBER_FORMAT_02d equ 2
PNG_NUMBER_FORMAT_x equ 3 PNG_NUMBER_FORMAT_x equ 3
PNG_NUMBER_FORMAT_02x equ 4 PNG_NUMBER_FORMAT_02x equ 4
PNG_NUMBER_FORMAT_fixed equ 5 ;choose the signed API PNG_NUMBER_FORMAT_fixed equ 5 ;choose the signed API
; New defines and members adding in libpng-1.5.4 ; New defines and members adding in libpng-1.5.4
PNG_WARNING_PARAMETER_SIZE equ 32 PNG_WARNING_PARAMETER_SIZE equ 32
PNG_WARNING_PARAMETER_COUNT equ 8 ;Maximum 9; see pngerror.asm PNG_WARNING_PARAMETER_COUNT equ 8 ;Maximum 9; see pngerror.asm
PNG_CHUNK_WARNING equ 0 ;never an error PNG_CHUNK_WARNING equ 0 ;never an error
PNG_CHUNK_WRITE_ERROR equ 1 ;an error only on write PNG_CHUNK_WRITE_ERROR equ 1 ;an error only on write
PNG_CHUNK_ERROR equ 2 ;always an error PNG_CHUNK_ERROR equ 2 ;always an error
; ASCII to FP interfaces, currently only implemented if sCAL ; ASCII to FP interfaces, currently only implemented if sCAL
; support is required. ; support is required.
; MAX_DIGITS is actually the maximum number of characters in an sCAL ; MAX_DIGITS is actually the maximum number of characters in an sCAL
; width or height, derived from the precision (number of significant ; width or height, derived from the precision (number of significant
; digits - a build time settable option) and assumptions about the ; digits - a build time settable option) and assumptions about the
; maximum ridiculous exponent. ; maximum ridiculous exponent.
PNG_sCAL_MAX_DIGITS equ PNG_sCAL_PRECISION+1+1+10 ;. E exponent PNG_sCAL_MAX_DIGITS equ PNG_sCAL_PRECISION+1+1+10 ;. E exponent
; An internal API to validate the format of a floating point number. ; An internal API to validate the format of a floating point number.
; The result is the index of the next character. If the number is ; The result is the index of the next character. If the number is
; not valid it will be the index of a character in the supposed number. ; not valid it will be the index of a character in the supposed number.
; The format of a number is defined in the PNG extensions specification ; The format of a number is defined in the PNG extensions specification
; and this API is strictly conformant to that spec, not anyone elses! ; and this API is strictly conformant to that spec, not anyone elses!
; The format as a regular expression is: ; The format as a regular expression is:
; [+-]?[0-9]+.?([Ee][+-]?[0-9]+)? ; [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?
; or: ; or:
; [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)? ; [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?
; The complexity is that either integer or fraction must be present and the ; The complexity is that either integer or fraction must be present and the
; fraction is permitted to have no digits only if the integer is present. ; fraction is permitted to have no digits only if the integer is present.
; NOTE: The dangling E problem. ; NOTE: The dangling E problem.
; There is a PNG valid floating point number in the following: ; There is a PNG valid floating point number in the following:
; PNG floating point numbers are not greedy. ; PNG floating point numbers are not greedy.
; Working this out requires *TWO* character lookahead (because of the ; Working this out requires *TWO* character lookahead (because of the
; sign), the parser does not do this - it will fail at the 'r' - this ; sign), the parser does not do this - it will fail at the 'r' - this
; doesn't matter for PNG sCAL chunk values, but it requires more care ; doesn't matter for PNG sCAL chunk values, but it requires more care
; if the value were ever to be embedded in something more complex. Use ; if the value were ever to be embedded in something more complex. Use
; ANSI-C strtod if you need the lookahead. ; ANSI-C strtod if you need the lookahead.
; State table for the parser. ; State table for the parser.
PNG_FP_INTEGER equ 0 ;before or in integer PNG_FP_INTEGER equ 0 ;before or in integer
PNG_FP_FRACTION equ 1 ;before or in fraction PNG_FP_FRACTION equ 1 ;before or in fraction
PNG_FP_EXPONENT equ 2 ;before or in exponent PNG_FP_EXPONENT equ 2 ;before or in exponent
PNG_FP_STATE equ 3 ;mask for the above PNG_FP_STATE equ 3 ;mask for the above
PNG_FP_SAW_SIGN equ 4 ;Saw +/- in current state PNG_FP_SAW_SIGN equ 4 ;Saw +/- in current state
PNG_FP_SAW_DIGIT equ 8 ;Saw a digit in current state PNG_FP_SAW_DIGIT equ 8 ;Saw a digit in current state
PNG_FP_SAW_DOT equ 16 ;Saw a dot in current state PNG_FP_SAW_DOT equ 16 ;Saw a dot in current state
PNG_FP_SAW_E equ 32 ;Saw an E (or e) in current state PNG_FP_SAW_E equ 32 ;Saw an E (or e) in current state
PNG_FP_SAW_ANY equ 60 ;Saw any of the above 4 PNG_FP_SAW_ANY equ 60 ;Saw any of the above 4
; These three values don't affect the parser. They are set but not used. ; These three values don't affect the parser. They are set but not used.
PNG_FP_WAS_VALID equ 64 ;Preceding substring is a valid fp number PNG_FP_WAS_VALID equ 64 ;Preceding substring is a valid fp number
PNG_FP_NEGATIVE equ 128 ;A negative number, including "-0" PNG_FP_NEGATIVE equ 128 ;A negative number, including "-0"
PNG_FP_NONZERO equ 256 ;A non-zero value PNG_FP_NONZERO equ 256 ;A non-zero value
PNG_FP_STICKY equ 448 ;The above three flags PNG_FP_STICKY equ 448 ;The above three flags
; This is available for the caller to store in 'state' if required. Do not ; This is available for the caller to store in 'state' if required. Do not
; call the parser after setting it (the parser sometimes clears it.) ; call the parser after setting it (the parser sometimes clears it.)
PNG_FP_INVALID equ 512 ;Available for callers as a distinct value PNG_FP_INVALID equ 512 ;Available for callers as a distinct value
; Result codes for the parser (boolean - true meants ok, false means ; Result codes for the parser (boolean - true meants ok, false means
; not ok yet.) ; not ok yet.)
PNG_FP_MAYBE equ 0 ;The number may be valid in the future PNG_FP_MAYBE equ 0 ;The number may be valid in the future
PNG_FP_OK equ 1 ;The number is valid PNG_FP_OK equ 1 ;The number is valid
; The internal structure that png_image::opaque points to. ; The internal structure that png_image::opaque points to.
struct png_control struct png_control
png_ptr dd ? ;png_structp png_ptr dd ? ;png_structp
info_ptr dd ? ;png_infop info_ptr dd ? ;png_infop
error_buf dd ? ;voidp ;Always a jmp_buf at present. error_buf dd ? ;voidp ;Always a jmp_buf at present.
memory dd ? ;bytep ;Memory buffer. memory dd ? ;bytep ;Memory buffer.
size dd ? ;png_size_t ;Size of the memory buffer. size dd ? ;png_size_t ;Size of the memory buffer.
for_write dd ? ;uint ;:1;Otherwise it is a read structure for_write dd ? ;uint ;:1;Otherwise it is a read structure
owned_file dd ? ;uint ;:1;We own the file in io_ptr owned_file dd ? ;uint ;:1;We own the file in io_ptr
ends ends

View File

@@ -1,453 +1,453 @@
; pngstruct.inc - header file for PNG reference library ; pngstruct.inc - header file for PNG reference library
; Last changed in libpng 1.6.24 [August 4, 2016] ; Last changed in libpng 1.6.24 [August 4, 2016]
; Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson ; Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) ; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) ; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
; This code is released under the libpng license. ; This code is released under the libpng license.
; For conditions of distribution and use, see the disclaimer ; For conditions of distribution and use, see the disclaimer
; and license in png.inc ; and license in png.inc
; The structure that holds the information to read and write PNG files. ; The structure that holds the information to read and write PNG files.
; The only people who need to care about what is inside of this are the ; The only people who need to care about what is inside of this are the
; people who will be modifying the library for their own special needs. ; people who will be modifying the library for their own special needs.
; It should NOT be accessed directly by an application. ; It should NOT be accessed directly by an application.
; zlib.inc defines the structure z_stream, an instance of which is included ; zlib.inc defines the structure z_stream, an instance of which is included
; in this structure and is required for decompressing the LZ compressed ; in this structure and is required for decompressing the LZ compressed
; data in PNG files. ; data in PNG files.
include '../../../../../../fs/kfar/trunk/zlib/zlib.inc' include '../../../../../../fs/kfar/trunk/zlib/zlib.inc'
; zlib.inc declares a magic type 'uInt' that limits the amount of data that zlib ; zlib.inc declares a magic type 'uInt' that limits the amount of data that zlib
; can handle at once. This type need be no larger than 16 bits (so maximum of ; can handle at once. This type need be no larger than 16 bits (so maximum of
; 65535), this define allows us to discover how big it is, but limited by the ; 65535), this define allows us to discover how big it is, but limited by the
; maximuum for png_size_t. The value can be overriden in a library build ; maximuum for png_size_t. The value can be overriden in a library build
; (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably ; (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
; lower value (e.g. 255 works). A lower value may help memory usage (slightly) ; lower value (e.g. 255 works). A lower value may help memory usage (slightly)
; and may even improve performance on some systems (and degrade it on others.) ; and may even improve performance on some systems (and degrade it on others.)
ZLIB_IO_MAX equ 0xffff ;-1 ;uInt ZLIB_IO_MAX equ 0xffff ;-1 ;uInt
; The type of a compression buffer list used by the write code. ; The type of a compression buffer list used by the write code.
struct png_compression_buffer struct png_compression_buffer
next dd ? ;struct png_compression_buffer * next dd ? ;struct png_compression_buffer *
output db ? ;byte[1] ;actually zbuf_size output db ? ;byte[1] ;actually zbuf_size
ends ends
macro PNG_COMPRESSION_BUFFER_SIZE pp macro PNG_COMPRESSION_BUFFER_SIZE pp
{ {
mov eax,png_compression_buffer.output mov eax,png_compression_buffer.output
add eax,[pp+png_struct.zbuffer_size] add eax,[pp+png_struct.zbuffer_size]
} }
; Colorspace support; structures used in png_struct, png_info and in internal ; Colorspace support; structures used in png_struct, png_info and in internal
; functions to hold and communicate information about the color space. ; functions to hold and communicate information about the color space.
; PNG_COLORSPACE_SUPPORTED is only required if the application will perform ; PNG_COLORSPACE_SUPPORTED is only required if the application will perform
; colorspace corrections, otherwise all the colorspace information can be ; colorspace corrections, otherwise all the colorspace information can be
; skipped and the size of libpng can be reduced (significantly) by compiling ; skipped and the size of libpng can be reduced (significantly) by compiling
; out the colorspace support. ; out the colorspace support.
if PNG_COLORSPACE_SUPPORTED eq 1 if PNG_COLORSPACE_SUPPORTED eq 1
; The chromaticities of the red, green and blue colorants and the chromaticity ; The chromaticities of the red, green and blue colorants and the chromaticity
; of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)). ; of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
struct png_xy struct png_xy
redx dd ? ;png_fixed_point redx dd ? ;png_fixed_point
redy dd ? redy dd ?
greenx dd ? greenx dd ?
greeny dd ? greeny dd ?
bluex dd ? bluex dd ?
bluey dd ? bluey dd ?
whitex dd ? whitex dd ?
whitey dd ? whitey dd ?
ends ends
; The same data as above but encoded as CIE XYZ values. When this data comes ; The same data as above but encoded as CIE XYZ values. When this data comes
; from chromaticities the sum of the Y values is assumed to be 1.0 ; from chromaticities the sum of the Y values is assumed to be 1.0
struct png_XYZ struct png_XYZ
red_X dd ? ;png_fixed_point red_X dd ? ;png_fixed_point
red_Y dd ? red_Y dd ?
red_Z dd ? red_Z dd ?
green_X dd ? green_X dd ?
green_Y dd ? green_Y dd ?
green_Z dd ? green_Z dd ?
blue_X dd ? blue_X dd ?
blue_Y dd ? blue_Y dd ?
blue_Z dd ? blue_Z dd ?
ends ends
end if ;COLORSPACE end if ;COLORSPACE
if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1) if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
; A colorspace is all the above plus, potentially, profile information; ; A colorspace is all the above plus, potentially, profile information;
; however at present libpng does not use the profile internally so it is only ; however at present libpng does not use the profile internally so it is only
; stored in the png_info struct (if iCCP is supported.) The rendering intent ; stored in the png_info struct (if iCCP is supported.) The rendering intent
; is retained here and is checked. ; is retained here and is checked.
; The file gamma encoding information is also stored here and gamma correction ; The file gamma encoding information is also stored here and gamma correction
; is done by libpng, whereas color correction must currently be done by the ; is done by libpng, whereas color correction must currently be done by the
; application. ; application.
struct png_colorspace struct png_colorspace
if PNG_GAMMA_SUPPORTED eq 1 if PNG_GAMMA_SUPPORTED eq 1
gamma dd ? ;png_fixed_point ;File gamma gamma dd ? ;png_fixed_point ;File gamma
end if end if
if PNG_COLORSPACE_SUPPORTED eq 1 if PNG_COLORSPACE_SUPPORTED eq 1
end_points_xy png_xy ;End points as chromaticities end_points_xy png_xy ;End points as chromaticities
end_points_XYZ png_XYZ ;End points as CIE XYZ colorant values end_points_XYZ png_XYZ ;End points as CIE XYZ colorant values
rendering_intent dw ? ;uint_16 ;Rendering intent of a profile rendering_intent dw ? ;uint_16 ;Rendering intent of a profile
end if end if
; Flags are always defined to simplify the code. ; Flags are always defined to simplify the code.
flags dw ? ;uint_16 ;As defined below flags dw ? ;uint_16 ;As defined below
ends ends
; General flags for the 'flags' field ; General flags for the 'flags' field
PNG_COLORSPACE_HAVE_GAMMA equ 0x0001 PNG_COLORSPACE_HAVE_GAMMA equ 0x0001
PNG_COLORSPACE_HAVE_ENDPOINTS equ 0x0002 PNG_COLORSPACE_HAVE_ENDPOINTS equ 0x0002
PNG_COLORSPACE_HAVE_INTENT equ 0x0004 PNG_COLORSPACE_HAVE_INTENT equ 0x0004
PNG_COLORSPACE_FROM_gAMA equ 0x0008 PNG_COLORSPACE_FROM_gAMA equ 0x0008
PNG_COLORSPACE_FROM_cHRM equ 0x0010 PNG_COLORSPACE_FROM_cHRM equ 0x0010
PNG_COLORSPACE_FROM_sRGB equ 0x0020 PNG_COLORSPACE_FROM_sRGB equ 0x0020
PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB equ 0x0040 PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB equ 0x0040
PNG_COLORSPACE_MATCHES_sRGB equ 0x0080 ;exact match on profile PNG_COLORSPACE_MATCHES_sRGB equ 0x0080 ;exact match on profile
PNG_COLORSPACE_INVALID equ 0x8000 PNG_COLORSPACE_INVALID equ 0x8000
macro PNG_COLORSPACE_CANCEL flags {(0xffff xor (flags))} macro PNG_COLORSPACE_CANCEL flags {(0xffff xor (flags))}
end if ;COLORSPACE || GAMMA end if ;COLORSPACE || GAMMA
struct png_struct struct png_struct
if PNG_SETJMP_SUPPORTED eq 1 if PNG_SETJMP_SUPPORTED eq 1
jmp_buf_local rb 64 ;jmp_buf ;New name in 1.6.0 for jmp_buf in png_struct jmp_buf_local rb 64 ;jmp_buf ;New name in 1.6.0 for jmp_buf in png_struct
longjmp_fn dd ? ;png_longjmp_ptr ;setjmp non-local goto function. longjmp_fn dd ? ;png_longjmp_ptr ;setjmp non-local goto function.
jmp_buf_ptr dd ? ;jmp_buf * ;passed to longjmp_fn jmp_buf_ptr dd ? ;jmp_buf * ;passed to longjmp_fn
jmp_buf_size dd ? ;size_t ;size of the above, if allocated jmp_buf_size dd ? ;size_t ;size of the above, if allocated
end if end if
error_fn dd ? ;png_error_ptr ;function for printing errors and aborting error_fn dd ? ;png_error_ptr ;function for printing errors and aborting
if PNG_WARNINGS_SUPPORTED eq 1 if PNG_WARNINGS_SUPPORTED eq 1
warning_fn dd ? ;png_error_ptr ;function for printing warnings warning_fn dd ? ;png_error_ptr ;function for printing warnings
end if end if
error_ptr dd ? ;voidp ;user supplied struct for error functions error_ptr dd ? ;voidp ;user supplied struct for error functions
write_data_fn dd ? ;png_rw_ptr ;function for writing output data write_data_fn dd ? ;png_rw_ptr ;function for writing output data
read_data_fn dd ? ;png_rw_ptr ;function for reading input data read_data_fn dd ? ;png_rw_ptr ;function for reading input data
io_ptr dd ? ;voidp ;ptr to application struct for I/O functions io_ptr dd ? ;voidp ;ptr to application struct for I/O functions
if PNG_READ_USER_TRANSFORM_SUPPORTED eq 1 if PNG_READ_USER_TRANSFORM_SUPPORTED eq 1
read_user_transform_fn dd ? ;png_user_transform_ptr ;user read transform read_user_transform_fn dd ? ;png_user_transform_ptr ;user read transform
end if end if
if PNG_WRITE_USER_TRANSFORM_SUPPORTED eq 1 if PNG_WRITE_USER_TRANSFORM_SUPPORTED eq 1
write_user_transform_fn dd ? ;png_user_transform_ptr ; user write transform write_user_transform_fn dd ? ;png_user_transform_ptr ; user write transform
end if end if
; These were added in libpng-1.0.2 ; These were added in libpng-1.0.2
if PNG_USER_TRANSFORM_PTR_SUPPORTED eq 1 if PNG_USER_TRANSFORM_PTR_SUPPORTED eq 1
if (PNG_READ_USER_TRANSFORM_SUPPORTED eq 1) | (PNG_WRITE_USER_TRANSFORM_SUPPORTED eq 1) if (PNG_READ_USER_TRANSFORM_SUPPORTED eq 1) | (PNG_WRITE_USER_TRANSFORM_SUPPORTED eq 1)
user_transform_ptr dd ? ;voidp ;user supplied struct for user transform user_transform_ptr dd ? ;voidp ;user supplied struct for user transform
user_transform_depth db ? ;byte ;bit depth of user transformed pixels user_transform_depth db ? ;byte ;bit depth of user transformed pixels
user_transform_channels db ? ;byte ;channels in user transformed pixels user_transform_channels db ? ;byte ;channels in user transformed pixels
rb 2 ;align rb 2 ;align
end if end if
end if end if
mode dd ? ;uint_32 ;tells us where we are in the PNG file mode dd ? ;uint_32 ;tells us where we are in the PNG file
flags dd ? ;uint_32 ;flags indicating various things to libpng flags dd ? ;uint_32 ;flags indicating various things to libpng
transformations dd ? ;uint_32 ;which transformations to perform transformations dd ? ;uint_32 ;which transformations to perform
zowner dd ? ;uint_32 ;ID (chunk type) of zstream owner, 0 if none zowner dd ? ;uint_32 ;ID (chunk type) of zstream owner, 0 if none
zstream z_stream ;decompression structure zstream z_stream ;decompression structure
zbuffer_list dd ? ;png_compression_bufferp ;Created on demand during write zbuffer_list dd ? ;png_compression_bufferp ;Created on demand during write
zbuffer_size dd ? ;uInt ;size of the actual buffer zbuffer_size dd ? ;uInt ;size of the actual buffer
zlib_level dd ? ;int ;holds zlib compression level zlib_level dd ? ;int ;holds zlib compression level
zlib_method dd ? ;int ;holds zlib compression method zlib_method dd ? ;int ;holds zlib compression method
zlib_window_bits dd ? ;int ;holds zlib compression window bits zlib_window_bits dd ? ;int ;holds zlib compression window bits
zlib_mem_level dd ? ;int ;holds zlib compression memory level zlib_mem_level dd ? ;int ;holds zlib compression memory level
zlib_strategy dd ? ;int ;holds zlib compression strategy zlib_strategy dd ? ;int ;holds zlib compression strategy
; Added at libpng 1.5.4 ; Added at libpng 1.5.4
if PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED eq 1 if PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED eq 1
zlib_text_level dd ? ;int ;holds zlib compression level zlib_text_level dd ? ;int ;holds zlib compression level
zlib_text_method dd ? ;int ;holds zlib compression method zlib_text_method dd ? ;int ;holds zlib compression method
zlib_text_window_bits dd ? ;int ;holds zlib compression window bits zlib_text_window_bits dd ? ;int ;holds zlib compression window bits
zlib_text_mem_level dd ? ;int ;holds zlib compression memory level zlib_text_mem_level dd ? ;int ;holds zlib compression memory level
zlib_text_strategy dd ? ;int ;holds zlib compression strategy zlib_text_strategy dd ? ;int ;holds zlib compression strategy
end if end if
;End of material added at libpng 1.5.4 ;End of material added at libpng 1.5.4
;Added at libpng 1.6.0 ;Added at libpng 1.6.0
zlib_set_level dd ? ;int ;Actual values set into the zstream on write zlib_set_level dd ? ;int ;Actual values set into the zstream on write
zlib_set_method dd ? ;int zlib_set_method dd ? ;int
zlib_set_window_bits dd ? ;int zlib_set_window_bits dd ? ;int
zlib_set_mem_level dd ? ;int zlib_set_mem_level dd ? ;int
zlib_set_strategy dd ? ;int zlib_set_strategy dd ? ;int
width dd ? ;uint_32 ;width of image in pixels width dd ? ;uint_32 ;width of image in pixels
height dd ? ;uint_32 ;height of image in pixels height dd ? ;uint_32 ;height of image in pixels
num_rows dd ? ;uint_32 ;number of rows in current pass num_rows dd ? ;uint_32 ;number of rows in current pass
usr_width dd ? ;uint_32 ;width of row at start of write usr_width dd ? ;uint_32 ;width of row at start of write
rowbytes dd ? ;png_size_t ;size of row in bytes rowbytes dd ? ;png_size_t ;size of row in bytes
iwidth dd ? ;uint_32 ;width of current interlaced row in pixels iwidth dd ? ;uint_32 ;width of current interlaced row in pixels
row_number dd ? ;uint_32 ;current row in interlace pass row_number dd ? ;uint_32 ;current row in interlace pass
chunk_name dd ? ;uint_32 ;PNG_CHUNK() id of current chunk chunk_name dd ? ;uint_32 ;PNG_CHUNK() id of current chunk
prev_row dd ? ;bytep ;buffer to save previous (unfiltered) row. prev_row dd ? ;bytep ;buffer to save previous (unfiltered) row.
;While reading this is a pointer into ;While reading this is a pointer into
;big_prev_row; while writing it is separately ;big_prev_row; while writing it is separately
;allocated if needed. ;allocated if needed.
row_buf dd ? ;bytep ;buffer to save current (unfiltered) row. row_buf dd ? ;bytep ;buffer to save current (unfiltered) row.
;While reading, this is a pointer into ;While reading, this is a pointer into
;big_row_buf; while writing it is separately ;big_row_buf; while writing it is separately
;allocated. ;allocated.
if PNG_WRITE_FILTER_SUPPORTED eq 1 if PNG_WRITE_FILTER_SUPPORTED eq 1
try_row dd ? ;bytep ;buffer to save trial row when filtering try_row dd ? ;bytep ;buffer to save trial row when filtering
tst_row dd ? ;bytep ;buffer to save best trial row when filtering tst_row dd ? ;bytep ;buffer to save best trial row when filtering
end if end if
info_rowbytes dd ? ;png_size_t ;Added in 1.5.4: cache of updated row bytes info_rowbytes dd ? ;png_size_t ;Added in 1.5.4: cache of updated row bytes
idat_size dd ? ;uint_32 ;current IDAT size for read idat_size dd ? ;uint_32 ;current IDAT size for read
crc dd ? ;uint_32 ;current chunk CRC value crc dd ? ;uint_32 ;current chunk CRC value
palette dd ? ;png_colorp ;palette from the input file palette dd ? ;png_colorp ;palette from the input file
num_palette dw ? ;uint_16 ;number of color entries in palette num_palette dw ? ;uint_16 ;number of color entries in palette
rb 2 ;align rb 2 ;align
; Added at libpng-1.5.10 ; Added at libpng-1.5.10
if PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED eq 1 if PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED eq 1
num_palette_max dd ? ;int ;maximum palette index found in IDAT num_palette_max dd ? ;int ;maximum palette index found in IDAT
end if end if
num_trans dw ? ;uint_16 ;number of transparency values num_trans dw ? ;uint_16 ;number of transparency values
compression db ? ;byte ;file compression type (always 0) compression db ? ;byte ;file compression type (always 0)
filter db ? ;byte ;file filter type (always 0) filter db ? ;byte ;file filter type (always 0)
interlaced db ? ;byte ;PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 interlaced db ? ;byte ;PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7
pass db ? ;byte ;current interlace pass (0 - 6) pass db ? ;byte ;current interlace pass (0 - 6)
do_filter db ? ;byte ;row filter flags (see PNG_FILTER_ in png.inc) do_filter db ? ;byte ;row filter flags (see PNG_FILTER_ in png.inc)
color_type db ? ;byte ;color type of file color_type db ? ;byte ;color type of file
bit_depth db ? ;byte ;bit depth of file bit_depth db ? ;byte ;bit depth of file
usr_bit_depth db ? ;byte ;bit depth of users row: write only usr_bit_depth db ? ;byte ;bit depth of users row: write only
pixel_depth db ? ;byte ;number of bits per pixel pixel_depth db ? ;byte ;number of bits per pixel
channels db ? ;byte ;number of channels in file channels db ? ;byte ;number of channels in file
usr_channels db ? ;byte ;channels at start of write: write only usr_channels db ? ;byte ;channels at start of write: write only
sig_bytes db ? ;byte ;magic bytes read/written from start of file sig_bytes db ? ;byte ;magic bytes read/written from start of file
maximum_pixel_depth db ? ;byte ;pixel depth used for the row buffers maximum_pixel_depth db ? ;byte ;pixel depth used for the row buffers
transformed_pixel_depth db ? ;byte ;pixel depth after read/write transforms transformed_pixel_depth db ? ;byte ;pixel depth after read/write transforms
;if PNG_ZLIB_VERNUM >= 0x1240 ;if PNG_ZLIB_VERNUM >= 0x1240
;zstream_start db 1 ;byte ;at start of an input zlib stream ;zstream_start db 1 ;byte ;at start of an input zlib stream
;end if ;Zlib >= 1.2.4 ;end if ;Zlib >= 1.2.4
if (PNG_READ_FILLER_SUPPORTED eq 1) | (PNG_WRITE_FILLER_SUPPORTED eq 1) if (PNG_READ_FILLER_SUPPORTED eq 1) | (PNG_WRITE_FILLER_SUPPORTED eq 1)
filler dw ? ;uint_16 ;filler bytes for pixel expansion filler dw ? ;uint_16 ;filler bytes for pixel expansion
end if end if
if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \ if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \
(PNG_READ_ALPHA_MODE_SUPPORTED eq 1) (PNG_READ_ALPHA_MODE_SUPPORTED eq 1)
background_gamma_type db ? ;byte background_gamma_type db ? ;byte
rb 1 ;align rb 1 ;align
background_gamma dd ? ;png_fixed_point background_gamma dd ? ;png_fixed_point
background png_color_16 ;background color in screen gamma space background png_color_16 ;background color in screen gamma space
rb 1 ;align rb 1 ;align
if PNG_READ_GAMMA_SUPPORTED eq 1 if PNG_READ_GAMMA_SUPPORTED eq 1
background_1 png_color_16 ;background normalized to gamma 1.0 background_1 png_color_16 ;background normalized to gamma 1.0
rb 1 ;align rb 1 ;align
end if end if
end if ;bKGD end if ;bKGD
if PNG_WRITE_FLUSH_SUPPORTED eq 1 if PNG_WRITE_FLUSH_SUPPORTED eq 1
output_flush_fn dd ? ;png_flush_ptr ;Function for flushing output output_flush_fn dd ? ;png_flush_ptr ;Function for flushing output
flush_dist dd ? ;uint_32 ;how many rows apart to flush, 0 - no flush flush_dist dd ? ;uint_32 ;how many rows apart to flush, 0 - no flush
flush_rows dd ? ;uint_32 ;number of rows written since last flush flush_rows dd ? ;uint_32 ;number of rows written since last flush
end if end if
if PNG_READ_GAMMA_SUPPORTED eq 1 if PNG_READ_GAMMA_SUPPORTED eq 1
gamma_shift dd ? ;int ;number of "insignificant" bits in 16-bit gamma gamma_shift dd ? ;int ;number of "insignificant" bits in 16-bit gamma
screen_gamma dd ? ;png_fixed_point ;screen gamma value (display_exponent) screen_gamma dd ? ;png_fixed_point ;screen gamma value (display_exponent)
gamma_table dd ? ;bytep ;gamma table for 8-bit depth files gamma_table dd ? ;bytep ;gamma table for 8-bit depth files
gamma_16_table dd ? ;uint_16pp ;gamma table for 16-bit depth files gamma_16_table dd ? ;uint_16pp ;gamma table for 16-bit depth files
if (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \ if (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \
(PNG_READ_ALPHA_MODE_SUPPORTED eq 1) | \ (PNG_READ_ALPHA_MODE_SUPPORTED eq 1) | \
(PNG_READ_RGB_TO_GRAY_SUPPORTED eq 1) (PNG_READ_RGB_TO_GRAY_SUPPORTED eq 1)
gamma_from_1 dd ? ;bytep ;converts from 1.0 to screen gamma_from_1 dd ? ;bytep ;converts from 1.0 to screen
gamma_to_1 dd ? ;bytep ;converts from file to 1.0 gamma_to_1 dd ? ;bytep ;converts from file to 1.0
gamma_16_from_1 dd ? ;uint_16pp ;converts from 1.0 to screen gamma_16_from_1 dd ? ;uint_16pp ;converts from 1.0 to screen
gamma_16_to_1 dd ? ;uint_16pp ;converts from file to 1.0 gamma_16_to_1 dd ? ;uint_16pp ;converts from file to 1.0
end if ;READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY end if ;READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY
end if end if
if (PNG_READ_GAMMA_SUPPORTED eq 1) | (PNG_sBIT_SUPPORTED eq 1) if (PNG_READ_GAMMA_SUPPORTED eq 1) | (PNG_sBIT_SUPPORTED eq 1)
sig_bit png_color_8 ;significant bits in each available channel sig_bit png_color_8 ;significant bits in each available channel
end if end if
if (PNG_READ_SHIFT_SUPPORTED eq 1) | (PNG_WRITE_SHIFT_SUPPORTED eq 1) if (PNG_READ_SHIFT_SUPPORTED eq 1) | (PNG_WRITE_SHIFT_SUPPORTED eq 1)
shift png_color_8 ;shift for significant bit tranformation shift png_color_8 ;shift for significant bit tranformation
rb 2 ;align rb 2 ;align
end if end if
if (PNG_tRNS_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) \ if (PNG_tRNS_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) \
| (PNG_READ_EXPAND_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) | (PNG_READ_EXPAND_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
trans_alpha dd ? ;bytep ;alpha values for paletted files trans_alpha dd ? ;bytep ;alpha values for paletted files
trans_color png_color_16 ;transparent color for non-paletted files trans_color png_color_16 ;transparent color for non-paletted files
rb 3 ;align rb 3 ;align
end if end if
read_row_fn dd ? ;png_read_status_ptr ;called after each row is decoded read_row_fn dd ? ;png_read_status_ptr ;called after each row is decoded
write_row_fn dd ? ;png_write_status_ptr ;called after each row is encoded write_row_fn dd ? ;png_write_status_ptr ;called after each row is encoded
if PNG_PROGRESSIVE_READ_SUPPORTED eq 1 if PNG_PROGRESSIVE_READ_SUPPORTED eq 1
info_fn dd ? ;png_progressive_info_ptr ;called after header data fully read info_fn dd ? ;png_progressive_info_ptr ;called after header data fully read
row_fn dd ? ;png_progressive_row_ptr ;called after a prog. row is decoded row_fn dd ? ;png_progressive_row_ptr ;called after a prog. row is decoded
end_fn dd ? ;png_progressive_end_ptr ;called after image is complete end_fn dd ? ;png_progressive_end_ptr ;called after image is complete
save_buffer_ptr dd ? ;bytep ;current location in save_buffer save_buffer_ptr dd ? ;bytep ;current location in save_buffer
save_buffer dd ? ;bytep ;buffer for previously read data save_buffer dd ? ;bytep ;buffer for previously read data
current_buffer_ptr dd ? ;bytep ;current location in current_buffer current_buffer_ptr dd ? ;bytep ;current location in current_buffer
current_buffer dd ? ;bytep ;buffer for recently used data current_buffer dd ? ;bytep ;buffer for recently used data
push_length dd ? ;uint_32 ;size of current input chunk push_length dd ? ;uint_32 ;size of current input chunk
skip_length dd ? ;uint_32 ;bytes to skip in input data skip_length dd ? ;uint_32 ;bytes to skip in input data
save_buffer_size dd ? ;png_size_t ;amount of data now in save_buffer save_buffer_size dd ? ;png_size_t ;amount of data now in save_buffer
save_buffer_max dd ? ;png_size_t ;total size of save_buffer save_buffer_max dd ? ;png_size_t ;total size of save_buffer
buffer_size dd ? ;png_size_t ;total amount of available input data buffer_size dd ? ;png_size_t ;total amount of available input data
current_buffer_size dd ? ;png_size_t ;amount of data now in current_buffer current_buffer_size dd ? ;png_size_t ;amount of data now in current_buffer
process_mode dd ? ;int ;what push library is currently doing process_mode dd ? ;int ;what push library is currently doing
cur_palette dd ? ;int ;current push library palette index cur_palette dd ? ;int ;current push library palette index
end if ;PROGRESSIVE_READ end if ;PROGRESSIVE_READ
if PNG_READ_QUANTIZE_SUPPORTED eq 1 if PNG_READ_QUANTIZE_SUPPORTED eq 1
palette_lookup dd ? ;bytep ;lookup table for quantizing palette_lookup dd ? ;bytep ;lookup table for quantizing
quantize_index dd ? ;bytep ;index translation for palette files quantize_index dd ? ;bytep ;index translation for palette files
end if end if
; Options ; Options
if PNG_SET_OPTION_SUPPORTED eq 1 if PNG_SET_OPTION_SUPPORTED eq 1
options db ? ;byte ;On/off state (up to 4 options) options db ? ;byte ;On/off state (up to 4 options)
end if end if
;#if PNG_LIBPNG_VER < 10700 ;#if PNG_LIBPNG_VER < 10700
; To do: remove this from libpng-1.7 ; To do: remove this from libpng-1.7
if PNG_TIME_RFC1123_SUPPORTED eq 1 if PNG_TIME_RFC1123_SUPPORTED eq 1
time_buffer rb 29 ;char[29] ;String to hold RFC 1123 time text time_buffer rb 29 ;char[29] ;String to hold RFC 1123 time text
rb 2 ;align rb 2 ;align
end if end if
;end if ;end if
; New members added in libpng-1.0.6 ; New members added in libpng-1.0.6
free_me dd ? ;uint_32 ;flags items libpng is responsible for freeing free_me dd ? ;uint_32 ;flags items libpng is responsible for freeing
if PNG_USER_CHUNKS_SUPPORTED eq 1 if PNG_USER_CHUNKS_SUPPORTED eq 1
user_chunk_ptr dd ? ;voidp user_chunk_ptr dd ? ;voidp
if PNG_READ_USER_CHUNKS_SUPPORTED eq 1 if PNG_READ_USER_CHUNKS_SUPPORTED eq 1
read_user_chunk_fn dd ? ;png_user_chunk_ptr ;user read chunk handler read_user_chunk_fn dd ? ;png_user_chunk_ptr ;user read chunk handler
end if end if
end if end if
if PNG_SET_UNKNOWN_CHUNKS_SUPPORTED eq 1 if PNG_SET_UNKNOWN_CHUNKS_SUPPORTED eq 1
unknown_default dd ? ;int ; As PNG_HANDLE_* unknown_default dd ? ;int ; As PNG_HANDLE_*
num_chunk_list dd ? ;unsigned int ; Number of entries in the list num_chunk_list dd ? ;unsigned int ; Number of entries in the list
chunk_list dd ? ;bytep ; List of byte[5]; the textual chunk name chunk_list dd ? ;bytep ; List of byte[5]; the textual chunk name
; followed by a PNG_HANDLE_* byte ; followed by a PNG_HANDLE_* byte
end if end if
; New members added in libpng-1.0.3 ; New members added in libpng-1.0.3
if PNG_READ_RGB_TO_GRAY_SUPPORTED eq 1 if PNG_READ_RGB_TO_GRAY_SUPPORTED eq 1
rgb_to_gray_status db ? ;byte rgb_to_gray_status db ? ;byte
; Added in libpng 1.5.5 to record setting of coefficients: ; Added in libpng 1.5.5 to record setting of coefficients:
rgb_to_gray_coefficients_set db ? ;byte rgb_to_gray_coefficients_set db ? ;byte
; These were changed from byte in libpng-1.0.6 ; These were changed from byte in libpng-1.0.6
rgb_to_gray_red_coeff dw ? ;uint_16 rgb_to_gray_red_coeff dw ? ;uint_16
rgb_to_gray_green_coeff dw ? ;uint_16 rgb_to_gray_green_coeff dw ? ;uint_16
; deleted in 1.5.5: rgb_to_gray_blue_coeff; ; deleted in 1.5.5: rgb_to_gray_blue_coeff;
rb 2 ;align rb 2 ;align
end if end if
if PNG_MNG_FEATURES_SUPPORTED eq 1 if PNG_MNG_FEATURES_SUPPORTED eq 1
; New member added in libpng-1.0.4 (renamed in 1.0.9) ; New member added in libpng-1.0.4 (renamed in 1.0.9)
; Changed from byte to uint_32 at version 1.2.0 ; Changed from byte to uint_32 at version 1.2.0
mng_features_permitted dd ? ;uint_32 mng_features_permitted dd ? ;uint_32
; New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 ; New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0
filter_type db ? ;byte filter_type db ? ;byte
rb 3 ;align rb 3 ;align
end if end if
; New members added in libpng-1.2.0 ; New members added in libpng-1.2.0
; New members added in libpng-1.0.2 but first enabled by default in 1.2.0 ; New members added in libpng-1.0.2 but first enabled by default in 1.2.0
if PNG_USER_MEM_SUPPORTED eq 1 if PNG_USER_MEM_SUPPORTED eq 1
mem_ptr dd ? ;voidp ;user supplied struct for mem functions mem_ptr dd ? ;voidp ;user supplied struct for mem functions
malloc_fn dd ? ;malloc_ptr ;function for allocating memory malloc_fn dd ? ;malloc_ptr ;function for allocating memory
free_fn dd ? ;free_ptr ;function for freeing memory free_fn dd ? ;free_ptr ;function for freeing memory
end if end if
; New member added in libpng-1.0.13 and 1.2.0 ; New member added in libpng-1.0.13 and 1.2.0
big_row_buf dd ? ;bytep ;buffer to save current (unfiltered) row big_row_buf dd ? ;bytep ;buffer to save current (unfiltered) row
if PNG_READ_QUANTIZE_SUPPORTED eq 1 if PNG_READ_QUANTIZE_SUPPORTED eq 1
; The following three members were added at version 1.0.14 and 1.2.4 ; The following three members were added at version 1.0.14 and 1.2.4
quantize_sort dd ? ;bytep ;working sort array quantize_sort dd ? ;bytep ;working sort array
index_to_palette dd ? ;bytep ;where the original index currently is in the palette index_to_palette dd ? ;bytep ;where the original index currently is in the palette
palette_to_index dd ? ;bytep ;which original index points to this palette color palette_to_index dd ? ;bytep ;which original index points to this palette color
end if end if
; New members added in libpng-1.0.16 and 1.2.6 ; New members added in libpng-1.0.16 and 1.2.6
compression_type db ? ;byte compression_type db ? ;byte
rb 3 ;align rb 3 ;align
if PNG_USER_LIMITS_SUPPORTED eq 1 if PNG_USER_LIMITS_SUPPORTED eq 1
user_width_max dd ? ;uint_32 user_width_max dd ? ;uint_32
user_height_max dd ? ;uint_32 user_height_max dd ? ;uint_32
; Added in libpng-1.4.0: Total number of sPLT, text, and unknown ; Added in libpng-1.4.0: Total number of sPLT, text, and unknown
; chunks that can be stored (0 means unlimited). ; chunks that can be stored (0 means unlimited).
user_chunk_cache_max dd ? ;uint_32 user_chunk_cache_max dd ? ;uint_32
; Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk ; Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
; can occupy when decompressed. 0 means unlimited. ; can occupy when decompressed. 0 means unlimited.
user_chunk_malloc_max dd ? ;png_alloc_size_t user_chunk_malloc_max dd ? ;png_alloc_size_t
end if end if
; New member added in libpng-1.0.25 and 1.2.17 ; New member added in libpng-1.0.25 and 1.2.17
if PNG_READ_UNKNOWN_CHUNKS_SUPPORTED eq 1 if PNG_READ_UNKNOWN_CHUNKS_SUPPORTED eq 1
; Temporary storage for unknown chunk that the library doesn't recognize, ; Temporary storage for unknown chunk that the library doesn't recognize,
; used while reading the chunk. ; used while reading the chunk.
unknown_chunk png_unknown_chunk unknown_chunk png_unknown_chunk
rb 3 ;align rb 3 ;align
end if end if
; New member added in libpng-1.2.26 ; New member added in libpng-1.2.26
old_big_row_buf_size dd ? ;png_size_t old_big_row_buf_size dd ? ;png_size_t
if PNG_READ_SUPPORTED eq 1 if PNG_READ_SUPPORTED eq 1
; New member added in libpng-1.2.30 ; New member added in libpng-1.2.30
read_buffer dd ? ;bytep ;buffer for reading chunk data read_buffer dd ? ;bytep ;buffer for reading chunk data
read_buffer_size dd ? ;png_alloc_size_t ;current size of the buffer read_buffer_size dd ? ;png_alloc_size_t ;current size of the buffer
end if end if
if PNG_SEQUENTIAL_READ_SUPPORTED eq 1 if PNG_SEQUENTIAL_READ_SUPPORTED eq 1
IDAT_read_size dd ? ;uInt ;limit on read buffer size for IDAT IDAT_read_size dd ? ;uInt ;limit on read buffer size for IDAT
end if end if
if PNG_IO_STATE_SUPPORTED eq 1 if PNG_IO_STATE_SUPPORTED eq 1
; New member added in libpng-1.4.0 ; New member added in libpng-1.4.0
io_state dd ? ;uint_32 io_state dd ? ;uint_32
end if end if
; New member added in libpng-1.5.6 ; New member added in libpng-1.5.6
big_prev_row dd ? ;bytep big_prev_row dd ? ;bytep
; New member added in libpng-1.5.7 ; New member added in libpng-1.5.7
read_filter rd PNG_FILTER_VALUE_LAST-1 read_filter rd PNG_FILTER_VALUE_LAST-1
if PNG_READ_SUPPORTED eq 1 if PNG_READ_SUPPORTED eq 1
if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1) if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
colorspace png_colorspace colorspace png_colorspace
end if end if
end if end if
ends ends

View File

@@ -1,299 +1,299 @@
txt_zv db '*',0 txt_zv db '*',0
txt_sp db ' ',0 txt_sp db ' ',0
txt_buf db '1234',0 txt_buf db '1234',0
rd 1 rd 1
buf_param rb 80 buf_param rb 80
macro cStr dest,txt macro cStr dest,txt
{ {
local .end_t local .end_t
local .m_txt local .m_txt
jmp .end_t jmp .end_t
align 4 align 4
.m_txt db txt,0 .m_txt db txt,0
align 4 align 4
.end_t: .end_t:
if dest eq if dest eq
mov eax,.m_txt mov eax,.m_txt
else else
mov dest,.m_txt mov dest,.m_txt
end if end if
} }
align 4 align 4
proc f_png_warning, h:dword, m_txt:dword proc f_png_warning, h:dword, m_txt:dword
stdcall hex_in_str,txt_buf,[h],5 stdcall hex_in_str,txt_buf,[h],5
mov byte[txt_buf+5],0 mov byte[txt_buf+5],0
stdcall dbg_print,txt_buf,[m_txt] stdcall dbg_print,txt_buf,[m_txt]
ret ret
endp endp
align 4 align 4
proc f_png_error, h:dword, m_txt:dword proc f_png_error, h:dword, m_txt:dword
stdcall hex_in_str,txt_buf,[h],5 stdcall hex_in_str,txt_buf,[h],5
mov byte[txt_buf+5],0 mov byte[txt_buf+5],0
stdcall dbg_print,txt_buf,[m_txt] stdcall dbg_print,txt_buf,[m_txt]
ret ret
endp endp
align 4 align 4
proc f_png_debug, n:dword, m_txt:dword proc f_png_debug, n:dword, m_txt:dword
stdcall dbg_print,txt_sp,[m_txt] stdcall dbg_print,txt_sp,[m_txt]
ret ret
endp endp
align 4 align 4
proc dbg_print, fun:dword, mes:dword proc dbg_print, fun:dword, mes:dword
pushad pushad
mov eax,SF_BOARD mov eax,SF_BOARD
mov ebx,SSF_DEBUG_WRITE mov ebx,SSF_DEBUG_WRITE
mov esi,[fun] mov esi,[fun]
cmp esi,0 cmp esi,0
je .end0 je .end0
@@: @@:
mov cl,byte[esi] mov cl,byte[esi]
int 0x40 int 0x40
inc esi inc esi
cmp byte[esi],0 cmp byte[esi],0
jne @b jne @b
mov cl,':' mov cl,':'
int 0x40 int 0x40
mov cl,' ' mov cl,' '
int 0x40 int 0x40
.end0: .end0:
mov esi,[mes] mov esi,[mes]
cmp esi,0 cmp esi,0
je .end_f je .end_f
@@: @@:
mov cl,byte[esi] mov cl,byte[esi]
cmp cl,0 cmp cl,0
je .end_f je .end_f
int 0x40 int 0x40
inc esi inc esi
jmp @b jmp @b
.end_f: .end_f:
popad popad
ret ret
endp endp
;input: ;input:
; zif - 1...8 ; zif - 1...8
align 4 align 4
proc hex_in_str, buf:dword,val:dword,zif:dword proc hex_in_str, buf:dword,val:dword,zif:dword
pushad pushad
mov edi,dword[buf] mov edi,dword[buf]
mov ecx,dword[zif] mov ecx,dword[zif]
add edi,ecx add edi,ecx
dec edi dec edi
mov ebx,dword[val] mov ebx,dword[val]
.cycle: .cycle:
mov al,bl mov al,bl
and al,0xf and al,0xf
cmp al,10 cmp al,10
jl @f jl @f
add al,'a'-'0'-10 add al,'a'-'0'-10
@@: @@:
add al,'0' add al,'0'
mov byte[edi],al mov byte[edi],al
dec edi dec edi
shr ebx,4 shr ebx,4
loop .cycle loop .cycle
popad popad
ret ret
endp endp
;--- ;---
macro png_warning h,txt macro png_warning h,txt
{ {
if txt eqtype '' if txt eqtype ''
local .end_t local .end_t
local .m_txt local .m_txt
jmp .end_t jmp .end_t
.m_txt db txt,13,10,0 .m_txt db txt,13,10,0
.end_t: .end_t:
stdcall f_png_warning,h,.m_txt stdcall f_png_warning,h,.m_txt
else else
stdcall f_png_warning,h,txt stdcall f_png_warning,h,txt
push eax ebx ecx push eax ebx ecx
mcall SF_BOARD,SSF_DEBUG_WRITE,13 mcall SF_BOARD,SSF_DEBUG_WRITE,13
mcall ,,10 mcall ,,10
pop ecx ebx eax pop ecx ebx eax
end if end if
} }
macro png_app_warning h,txt macro png_app_warning h,txt
{ {
png_warning h,<txt> png_warning h,<txt>
} }
macro png_error h,txt macro png_error h,txt
{ {
if txt eqtype '' if txt eqtype ''
local .end_t local .end_t
local .m_txt local .m_txt
jmp .end_t jmp .end_t
.m_txt db txt,13,10,0 .m_txt db txt,13,10,0
.end_t: .end_t:
stdcall f_png_error,h,.m_txt stdcall f_png_error,h,.m_txt
else else
stdcall f_png_error,h,txt stdcall f_png_error,h,txt
push eax ebx ecx push eax ebx ecx
mcall SF_BOARD,SSF_DEBUG_WRITE,13 mcall SF_BOARD,SSF_DEBUG_WRITE,13
mcall ,,10 mcall ,,10
pop ecx ebx eax pop ecx ebx eax
end if end if
} }
macro png_debug n,txt macro png_debug n,txt
{ {
if DEBUG eq 1 if DEBUG eq 1
local .end_t local .end_t
local .m_txt local .m_txt
jmp .end_t jmp .end_t
.m_txt db txt,13,10,0 .m_txt db txt,13,10,0
align 4 align 4
.end_t: .end_t:
stdcall f_png_debug,n,.m_txt stdcall f_png_debug,n,.m_txt
end if end if
} }
macro png_debug1 n,fmt,p1 macro png_debug1 n,fmt,p1
{ {
if DEBUG eq 1 if DEBUG eq 1
local .end_t local .end_t
if p1 eqtype '' if p1 eqtype ''
local .m_txt1 local .m_txt1
local .m_txt2 local .m_txt2
jmp .end_t jmp .end_t
.m_txt1 db fmt,0 .m_txt1 db fmt,0
.m_txt2 db p1,13,10,0 .m_txt2 db p1,13,10,0
align 4 align 4
.end_t: .end_t:
stdcall dbg_print,.m_txt1,.m_txt2 stdcall dbg_print,.m_txt1,.m_txt2
else else
local .m_fmt local .m_fmt
jmp .end_t jmp .end_t
.m_fmt db fmt,13,10,0 .m_fmt db fmt,13,10,0
align 4 align 4
.end_t: .end_t:
stdcall str_format_dbg, buf_param,.m_fmt,p1 stdcall str_format_dbg, buf_param,.m_fmt,p1
end if end if
end if end if
} }
;output: ;output:
; eax = strlen ; eax = strlen
align 4 align 4
proc strlen, str1:dword proc strlen, str1:dword
mov eax,[str1] mov eax,[str1]
@@: @@:
cmp byte[eax],0 cmp byte[eax],0
je @f je @f
inc eax inc eax
jmp @b jmp @b
@@: @@:
sub eax,[str1] sub eax,[str1]
ret ret
endp endp
align 4 align 4
proc str_format_dbg, buf:dword, fmt:dword, p1:dword proc str_format_dbg, buf:dword, fmt:dword, p1:dword
pushad pushad
mov esi,[fmt] mov esi,[fmt]
mov edi,[buf] mov edi,[buf]
mov ecx,80-1 mov ecx,80-1
.cycle0: .cycle0:
lodsb lodsb
cmp al,'%' cmp al,'%'
jne .no_param jne .no_param
lodsb lodsb
dec ecx dec ecx
cmp al,0 cmp al,0
je .cycle0end je .cycle0end
cmp al,'d' cmp al,'d'
je @f je @f
cmp al,'u' cmp al,'u'
je @f je @f
cmp al,'l' cmp al,'l'
je .end1 je .end1
jmp .end0 jmp .end0
.end1: ;%lu %lx .end1: ;%lu %lx
lodsb lodsb
dec ecx dec ecx
cmp al,'u' cmp al,'u'
jne .end0 jne .end0
@@: @@:
mov eax,[p1] mov eax,[p1]
stdcall convert_int_to_str,ecx stdcall convert_int_to_str,ecx
xor al,al xor al,al
repne scasb repne scasb
dec edi dec edi
.end0: .end0:
loop .cycle0 loop .cycle0
.no_param: .no_param:
stosb stosb
cmp al,0 cmp al,0
je .cycle0end je .cycle0end
loop .cycle0 loop .cycle0
.cycle0end: .cycle0end:
xor al,al xor al,al
stosb stosb
stdcall dbg_print,txt_sp,[buf] stdcall dbg_print,txt_sp,[buf]
popad popad
ret ret
endp endp
;input: ;input:
; eax - число ; eax - число
; edi - буфер для строки ; edi - буфер для строки
; len - длинна буфера ; len - длинна буфера
;output: ;output:
align 4 align 4
proc convert_int_to_str, len:dword proc convert_int_to_str, len:dword
pushad pushad
mov esi,[len] mov esi,[len]
add esi,edi add esi,edi
dec esi dec esi
call .str call .str
popad popad
ret ret
endp endp
align 4 align 4
.str: .str:
mov ecx,0x0a mov ecx,0x0a
cmp eax,ecx cmp eax,ecx
jb @f jb @f
xor edx,edx xor edx,edx
div ecx div ecx
push edx push edx
call .str call .str
pop eax pop eax
@@: @@:
cmp edi,esi cmp edi,esi
jge @f jge @f
or al,0x30 or al,0x30
stosb stosb
mov byte[edi],0 mov byte[edi],0
@@: @@:
ret ret
macro std_png_image_error n,txt macro std_png_image_error n,txt
{ {
local .end_t local .end_t
local .m_txt local .m_txt
jmp .end_t jmp .end_t
.m_txt db txt,13,10,0 .m_txt db txt,13,10,0
align 4 align 4
.end_t: .end_t:
stdcall png_image_error,n,.m_txt stdcall png_image_error,n,.m_txt
} }

View File

@@ -1,165 +1,165 @@
; pngwio.asm - functions for data output ; pngwio.asm - functions for data output
; Last changed in libpng 1.6.24 [August 4, 2016] ; Last changed in libpng 1.6.24 [August 4, 2016]
; Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson ; Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) ; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) ; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
; This code is released under the libpng license. ; This code is released under the libpng license.
; For conditions of distribution and use, see the disclaimer ; For conditions of distribution and use, see the disclaimer
; and license in png.inc ; and license in png.inc
; This file provides a location for all output. Users who need ; This file provides a location for all output. Users who need
; special handling are expected to write functions that have the same ; special handling are expected to write functions that have the same
; arguments as these and perform similar functions, but that possibly ; arguments as these and perform similar functions, but that possibly
; use different output methods. Note that you shouldn't change these ; use different output methods. Note that you shouldn't change these
; functions, but rather write replacement functions and then change ; functions, but rather write replacement functions and then change
; them at run time with png_set_write_fn(...). ; them at run time with png_set_write_fn(...).
; Write the data to whatever output you are using. The default routine ; Write the data to whatever output you are using. The default routine
; writes to a file pointer. Note that this routine sometimes gets called ; writes to a file pointer. Note that this routine sometimes gets called
; with very small lengths, so you should implement some kind of simple ; with very small lengths, so you should implement some kind of simple
; buffering if you are using unbuffered writes. This should never be asked ; buffering if you are using unbuffered writes. This should never be asked
; to write more than 64K on a 16-bit machine. ; to write more than 64K on a 16-bit machine.
;void (png_structrp png_ptr, bytep data, png_size_t length) ;void (png_structrp png_ptr, bytep data, png_size_t length)
align 4 align 4
proc png_write_data uses edi, png_ptr:dword, p2data:dword, length:dword proc png_write_data uses edi, png_ptr:dword, p2data:dword, length:dword
; NOTE: write_data_fn must not change the buffer! ; NOTE: write_data_fn must not change the buffer!
mov edi,[png_ptr] mov edi,[png_ptr]
cmp dword[edi+png_struct.write_data_fn],0 cmp dword[edi+png_struct.write_data_fn],0
je @f ;if (..!=0) je @f ;if (..!=0)
stdcall dword[edi+png_struct.write_data_fn], edi, [p2data], [length] stdcall dword[edi+png_struct.write_data_fn], edi, [p2data], [length]
jmp .end_f jmp .end_f
@@: ;else @@: ;else
png_error edi, 'Call to NULL write function' png_error edi, 'Call to NULL write function'
.end_f: .end_f:
ret ret
endp endp
; This is the function that does the actual writing of data. If you are ; This is the function that does the actual writing of data. If you are
; not writing to a standard C stream, you should create a replacement ; not writing to a standard C stream, you should create a replacement
; write_data function and use it at run time with png_set_write_fn(), rather ; write_data function and use it at run time with png_set_write_fn(), rather
; than changing the library. ; than changing the library.
;void (png_structp png_ptr, bytep data, png_size_t length) ;void (png_structp png_ptr, bytep data, png_size_t length)
align 4 align 4
proc png_default_write_data uses eax edi, png_ptr:dword, p2data:dword, length:dword proc png_default_write_data uses eax edi, png_ptr:dword, p2data:dword, length:dword
; png_size_t check; ; png_size_t check;
mov edi,[png_ptr] mov edi,[png_ptr]
cmp edi,0 cmp edi,0
je .end_f ;if (..==0) return je .end_f ;if (..==0) return
; check = fwrite(p2data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); ; check = fwrite(p2data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
; if (check != length) ; if (check != length)
; png_error(png_ptr, "Write Error"); ; png_error(png_ptr, "Write Error");
.end_f: .end_f:
ret ret
endp endp
; This function is called to output any data pending writing (normally ; This function is called to output any data pending writing (normally
; to disk). After png_flush is called, there should be no data pending ; to disk). After png_flush is called, there should be no data pending
; writing in any buffers. ; writing in any buffers.
;void (png_structrp png_ptr) ;void (png_structrp png_ptr)
align 4 align 4
proc png_flush uses edi, png_ptr:dword proc png_flush uses edi, png_ptr:dword
mov edi,[png_ptr] mov edi,[png_ptr]
cmp dword[edi+png_struct.output_flush_fn],0 cmp dword[edi+png_struct.output_flush_fn],0
je @f ;if (..!=..) je @f ;if (..!=..)
stdcall dword[edi+png_struct.output_flush_fn],edi stdcall dword[edi+png_struct.output_flush_fn],edi
@@: @@:
ret ret
endp endp
;void (png_structp png_ptr) ;void (png_structp png_ptr)
align 4 align 4
proc png_default_flush uses eax edi, png_ptr:dword proc png_default_flush uses eax edi, png_ptr:dword
mov edi,[png_ptr] mov edi,[png_ptr]
cmp edi,0 cmp edi,0
je @f ;if (..==0) return je @f ;if (..==0) return
;;; stdcall fflush, [edi+png_struct.io_ptr] ;;; stdcall fflush, [edi+png_struct.io_ptr]
@@: @@:
ret ret
endp endp
; This function allows the application to supply new output functions for ; This function allows the application to supply new output functions for
; libpng if standard C streams aren't being used. ; libpng if standard C streams aren't being used.
; This function takes as its arguments: ; This function takes as its arguments:
; png_ptr - pointer to a png output data structure ; png_ptr - pointer to a png output data structure
; io_ptr - pointer to user supplied structure containing info about ; io_ptr - pointer to user supplied structure containing info about
; the output functions. May be NULL. ; the output functions. May be NULL.
; write_data_fn - pointer to a new output function that takes as its ; write_data_fn - pointer to a new output function that takes as its
; arguments a pointer to a png_struct, a pointer to ; arguments a pointer to a png_struct, a pointer to
; data to be written, and a 32-bit unsigned int that is ; data to be written, and a 32-bit unsigned int that is
; the number of bytes to be written. The new write ; the number of bytes to be written. The new write
; function should call png_error(png_ptr, "Error msg") ; function should call png_error(png_ptr, "Error msg")
; to exit and output any fatal error messages. May be ; to exit and output any fatal error messages. May be
; NULL, in which case libpng's default function will ; NULL, in which case libpng's default function will
; be used. ; be used.
; flush_data_fn - pointer to a new flush function that takes as its ; flush_data_fn - pointer to a new flush function that takes as its
; arguments a pointer to a png_struct. After a call to ; arguments a pointer to a png_struct. After a call to
; the flush function, there should be no data in any buffers ; the flush function, there should be no data in any buffers
; or pending transmission. If the output method doesn't do ; or pending transmission. If the output method doesn't do
; any buffering of output, a function prototype must still be ; any buffering of output, a function prototype must still be
; supplied although it doesn't have to do anything. If ; supplied although it doesn't have to do anything. If
; PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile ; PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
; time, output_flush_fn will be ignored, although it must be ; time, output_flush_fn will be ignored, although it must be
; supplied for compatibility. May be NULL, in which case ; supplied for compatibility. May be NULL, in which case
; libpng's default function will be used, if ; libpng's default function will be used, if
; PNG_WRITE_FLUSH_SUPPORTED is defined. This is not ; PNG_WRITE_FLUSH_SUPPORTED is defined. This is not
; a good idea if io_ptr does not point to a standard ; a good idea if io_ptr does not point to a standard
; *FILE structure. ; *FILE structure.
;void (png_structrp png_ptr, voidp io_ptr, ;void (png_structrp png_ptr, voidp io_ptr,
; png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) ; png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
align 4 align 4
proc png_set_write_fn uses eax edi, png_ptr:dword, io_ptr:dword, write_data_fn:dword, output_flush_fn:dword proc png_set_write_fn uses eax edi, png_ptr:dword, io_ptr:dword, write_data_fn:dword, output_flush_fn:dword
mov edi,[png_ptr] mov edi,[png_ptr]
cmp edi,0 cmp edi,0
je .end_f ;if (..==0) return je .end_f ;if (..==0) return
mov eax,[io_ptr] mov eax,[io_ptr]
mov [edi+png_struct.io_ptr],eax mov [edi+png_struct.io_ptr],eax
if PNG_STDIO_SUPPORTED eq 1 if PNG_STDIO_SUPPORTED eq 1
mov eax,png_default_write_data ;else mov eax,png_default_write_data ;else
cmp dword[write_data_fn],0 cmp dword[write_data_fn],0
je @f ;if (..!=0) je @f ;if (..!=0)
mov eax,[write_data_fn] mov eax,[write_data_fn]
@@: @@:
else else
mov eax,[write_data_fn] mov eax,[write_data_fn]
end if end if
mov [edi+png_struct.write_data_fn],eax mov [edi+png_struct.write_data_fn],eax
if PNG_WRITE_FLUSH_SUPPORTED eq 1 if PNG_WRITE_FLUSH_SUPPORTED eq 1
if PNG_STDIO_SUPPORTED eq 1 if PNG_STDIO_SUPPORTED eq 1
mov eax,[png_default_flush] ;else mov eax,[png_default_flush] ;else
cmp dword[output_flush_fn],0 cmp dword[output_flush_fn],0
je @f ;if (..!=0) je @f ;if (..!=0)
mov eax,[output_flush_fn] mov eax,[output_flush_fn]
@@: @@:
else else
mov eax,[output_flush_fn] mov eax,[output_flush_fn]
end if end if
mov [edi+png_struct.output_flush_fn],eax mov [edi+png_struct.output_flush_fn],eax
end if ;WRITE_FLUSH end if ;WRITE_FLUSH
if PNG_READ_SUPPORTED eq 1 if PNG_READ_SUPPORTED eq 1
; It is an error to read while writing a png file ; It is an error to read while writing a png file
cmp dword[edi+png_struct.read_data_fn],0 cmp dword[edi+png_struct.read_data_fn],0
je @f ;if (..!=0) je @f ;if (..!=0)
mov dword[edi+png_struct.read_data_fn], 0 mov dword[edi+png_struct.read_data_fn], 0
png_warning edi, <'Can',39,'t set both read_data_fn and write_data_fn in the same structure'> png_warning edi, <'Can',39,'t set both read_data_fn and write_data_fn in the same structure'>
@@: @@:
end if end if
.end_f: .end_f:
ret ret
endp endp

File diff suppressed because it is too large Load Diff

View File

@@ -1,288 +1,288 @@
;;================================================================================================;; ;;================================================================================================;;
;;//// tga.asm //// (c) Nable, 2007-2008, (c) dunkaist, 2012 /////////////////////////////////////;; ;;//// tga.asm //// (c) Nable, 2007-2008, (c) dunkaist, 2012 /////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;; ;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;; ;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; ;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;; ;; of the License, or (at your option) any later version. ;;
;; ;; ;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; ;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; ;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;; ;; Lesser General Public License for more details. ;;
;; ;; ;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; ;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;; ;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; References: ;; ;; References: ;;
;; 1. Hiview 1.2 by Mohammad A. REZAEI ;; ;; 1. Hiview 1.2 by Mohammad A. REZAEI ;;
;; 2. Truevision TGA FILE FORMAT SPECIFICATION Version 2.0 ;; ;; 2. Truevision TGA FILE FORMAT SPECIFICATION Version 2.0 ;;
;; Technical Manual Version 2.2 January, 1991 ;; ;; Technical Manual Version 2.2 January, 1991 ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
include 'tga.inc' include 'tga.inc'
;;================================================================================================;; ;;================================================================================================;;
proc img.is.tga _data, _length ;//////////////////////////////////////////////////////////////////;; proc img.is.tga _data, _length ;//////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;? Determine if raw data could be decoded (is in Targa format) ;; ;? Determine if raw data could be decoded (is in Targa format) ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;> _data = raw data as read from file/stream ;; ;> _data = raw data as read from file/stream ;;
;> _length = data length ;; ;> _length = data length ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;; ;< eax = false / true ;;
;;================================================================================================;; ;;================================================================================================;;
push ebx push ebx
cmp [_length], 18 cmp [_length], 18
jbe .nope jbe .nope
mov ebx, [_data] mov ebx, [_data]
mov eax, dword[ebx + tga_header.colormap_type] mov eax, dword[ebx + tga_header.colormap_type]
cmp al, 1 cmp al, 1
ja .nope ja .nope
cmp ah, 11 cmp ah, 11
ja .nope ja .nope
cmp ah, 9 cmp ah, 9
jae .cont1 jae .cont1
cmp ah, 3 cmp ah, 3
ja .nope ja .nope
.cont1: .cont1:
mov eax, dword[ebx + tga_header.image_spec.depth] mov eax, dword[ebx + tga_header.image_spec.depth]
test eax, 111b ; bpp must be 8, 15, 16, 24 or 32 test eax, 111b ; bpp must be 8, 15, 16, 24 or 32
jnz .maybe15 jnz .maybe15
shr al, 3 shr al, 3
cmp al, 4 cmp al, 4
ja .nope ja .nope
jmp .cont2 jmp .cont2
.maybe15: .maybe15:
cmp al, 15 cmp al, 15
jne .nope jne .nope
.cont2: ; continue testing .cont2: ; continue testing
movzx eax, byte[ebx + tga_header.colormap_spec.entry_size] ; palette bpp movzx eax, byte[ebx + tga_header.colormap_spec.entry_size] ; palette bpp
cmp eax, 0 cmp eax, 0
je .yep je .yep
cmp eax, 16 cmp eax, 16
je .yep je .yep
cmp eax, 24 cmp eax, 24
je .yep je .yep
cmp eax, 32 cmp eax, 32
je .yep je .yep
.nope: .nope:
xor eax, eax xor eax, eax
pop ebx pop ebx
ret ret
.yep: .yep:
xor eax, eax xor eax, eax
inc eax inc eax
pop ebx pop ebx
ret ret
endp endp
;;================================================================================================;; ;;================================================================================================;;
proc img.decode.tga _data, _length, _options ;////////////////////////////////////////////////////;; proc img.decode.tga _data, _length, _options ;////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;? Decode data into image if it contains correctly formed raw data in Targa format ;; ;? Decode data into image if it contains correctly formed raw data in Targa format ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;> _data = raw data as read from file/stream ;; ;> _data = raw data as read from file/stream ;;
;> _length = data length ;; ;> _length = data length ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) or pointer to image ;; ;< eax = 0 (error) or pointer to image ;;
;;================================================================================================;; ;;================================================================================================;;
locals locals
width dd ? width dd ?
height dd ? height dd ?
bytes_per_pixel dd ? bytes_per_pixel dd ?
retvalue dd ? retvalue dd ?
endl endl
push ebx esi edi push ebx esi edi
mov ebx, [_data] mov ebx, [_data]
movzx esi, byte[ebx] movzx esi, byte[ebx]
lea esi, [esi + ebx + sizeof.tga_header] ; skip comment and header lea esi, [esi + ebx + sizeof.tga_header] ; skip comment and header
mov edx, dword[ebx + tga_header.image_spec.width] mov edx, dword[ebx + tga_header.image_spec.width]
movzx ecx, dx ; ecx = width movzx ecx, dx ; ecx = width
shr edx, 16 ; edx = height shr edx, 16 ; edx = height
mov [width], ecx mov [width], ecx
mov [height], edx mov [height], edx
movzx eax, byte[ebx + tga_header.image_spec.depth] movzx eax, byte[ebx + tga_header.image_spec.depth]
add eax, 7 add eax, 7
shr eax, 3 shr eax, 3
mov [bytes_per_pixel], eax mov [bytes_per_pixel], eax
movzx eax, byte[ebx + tga_header.image_spec.depth] movzx eax, byte[ebx + tga_header.image_spec.depth]
cmp eax, 8 cmp eax, 8
jne @f jne @f
mov eax, Image.bpp8i mov eax, Image.bpp8i
jmp .type_defined jmp .type_defined
@@: @@:
cmp eax, 15 cmp eax, 15
jne @f jne @f
mov eax, Image.bpp15 mov eax, Image.bpp15
jmp .type_defined jmp .type_defined
@@: @@:
cmp eax, 16 cmp eax, 16
jne @f jne @f
mov eax, Image.bpp15 ; 16bpp tga images are really 15bpp ARGB mov eax, Image.bpp15 ; 16bpp tga images are really 15bpp ARGB
jmp .type_defined jmp .type_defined
@@: @@:
cmp eax, 24 cmp eax, 24
jne @f jne @f
mov eax, Image.bpp24 mov eax, Image.bpp24
jmp .type_defined jmp .type_defined
@@: @@:
cmp eax, 32 cmp eax, 32
jne @f jne @f
mov eax, Image.bpp32 mov eax, Image.bpp32
jmp .type_defined jmp .type_defined
@@: @@:
.type_defined: .type_defined:
stdcall img.create, ecx, edx, eax stdcall img.create, ecx, edx, eax
mov [retvalue], eax mov [retvalue], eax
test eax, eax ; failed to allocate? test eax, eax ; failed to allocate?
jz .done ; then exit jz .done ; then exit
mov ebx, eax mov ebx, eax
cmp dword[ebx + Image.Type], Image.bpp8i cmp dword[ebx + Image.Type], Image.bpp8i
jne .palette_parsed jne .palette_parsed
mov edi, [ebx + Image.Palette] mov edi, [ebx + Image.Palette]
mov ecx, [_data] mov ecx, [_data]
cmp byte[ecx + tga_header.image_type], 3 ; we also have grayscale subtype cmp byte[ecx + tga_header.image_type], 3 ; we also have grayscale subtype
jz .write_grayscale_palette ; that don't hold palette in file jz .write_grayscale_palette ; that don't hold palette in file
cmp byte[ecx + tga_header.image_type], 11 cmp byte[ecx + tga_header.image_type], 11
jz .write_grayscale_palette jz .write_grayscale_palette
movzx eax, byte[ecx + tga_header.colormap_spec.entry_size] ; size of colormap entries in bits movzx eax, byte[ecx + tga_header.colormap_spec.entry_size] ; size of colormap entries in bits
movzx ecx, word[ecx + tga_header.colormap_spec.colormap_length] ; number of colormap entries movzx ecx, word[ecx + tga_header.colormap_spec.colormap_length] ; number of colormap entries
cmp eax, 24 cmp eax, 24
je .24bpp_palette je .24bpp_palette
cmp eax, 16 cmp eax, 16
je .16bpp_palette je .16bpp_palette
rep movsd ; else they are 32 bpp rep movsd ; else they are 32 bpp
jmp .palette_parsed jmp .palette_parsed
.write_grayscale_palette: .write_grayscale_palette:
mov ecx, 0x100 mov ecx, 0x100
xor eax, eax xor eax, eax
@@: @@:
stosd stosd
add eax, 0x010101 add eax, 0x010101
loop @b loop @b
jmp .palette_parsed jmp .palette_parsed
.16bpp_palette: ; FIXME: code copypasted from img.do_rgb, should use img.convert .16bpp_palette: ; FIXME: code copypasted from img.do_rgb, should use img.convert
push ebx edx ebp push ebx edx ebp
@@: @@:
movzx eax, word[esi] movzx eax, word[esi]
mov ebx, eax mov ebx, eax
add esi, 2 add esi, 2
and eax, (0x1F) or (0x1F shl 10) and eax, (0x1F) or (0x1F shl 10)
and ebx, 0x1F shl 5 and ebx, 0x1F shl 5
lea edx, [eax + eax] lea edx, [eax + eax]
shr al, 2 shr al, 2
mov ebp, ebx mov ebp, ebx
shr ebx, 2 shr ebx, 2
shr ah, 4 shr ah, 4
shl dl, 2 shl dl, 2
shr ebp, 7 shr ebp, 7
add eax, edx add eax, edx
add ebx, ebp add ebx, ebp
mov [edi], al mov [edi], al
mov [edi + 1], bl mov [edi + 1], bl
mov [edi + 2], ah mov [edi + 2], ah
add edi, 4 add edi, 4
loop @b loop @b
pop ebp edx ebx pop ebp edx ebx
jmp .palette_parsed jmp .palette_parsed
.24bpp_palette: .24bpp_palette:
@@: @@:
lodsd lodsd
dec esi dec esi
and eax, 0xffffff and eax, 0xffffff
stosd stosd
loop @b loop @b
.palette_parsed: .palette_parsed:
mov edi, [ebx + Image.Data] mov edi, [ebx + Image.Data]
mov ebx, [width] mov ebx, [width]
imul ebx, [height] imul ebx, [height]
mov edx, [bytes_per_pixel] mov edx, [bytes_per_pixel]
mov eax, [_data] mov eax, [_data]
test byte[eax + tga_header.image_type], 0x08 test byte[eax + tga_header.image_type], 0x08
jz .uncompressed jz .uncompressed
.next_rle_packet: .next_rle_packet:
xor eax, eax xor eax, eax
lodsb lodsb
btr ax, 7 ; Run-length packet? btr ax, 7 ; Run-length packet?
jnc .raw_packet jnc .raw_packet
add eax, 1 add eax, 1
sub ebx, eax sub ebx, eax
@@: @@:
mov ecx, edx mov ecx, edx
rep movsb rep movsb
sub esi, edx sub esi, edx
sub eax, 1 sub eax, 1
jnz @b jnz @b
add esi, edx add esi, edx
test ebx, ebx test ebx, ebx
jnz .next_rle_packet jnz .next_rle_packet
jmp .done jmp .done
.raw_packet: .raw_packet:
mov ecx, eax mov ecx, eax
add ecx, 1 add ecx, 1
sub ebx, ecx sub ebx, ecx
imul ecx, edx imul ecx, edx
rep movsb rep movsb
test ebx, ebx test ebx, ebx
jnz .next_rle_packet jnz .next_rle_packet
.uncompressed: .uncompressed:
imul edx, ebx imul edx, ebx
mov ecx, edx mov ecx, edx
rep movsb rep movsb
.done: .done:
xor ebx, ebx xor ebx, ebx
mov esi, [_data] mov esi, [_data]
test byte[esi + tga_header.image_spec.descriptor], TGA_START_TOP test byte[esi + tga_header.image_spec.descriptor], TGA_START_TOP
jnz @f jnz @f
or ebx, FLIP_VERTICAL or ebx, FLIP_VERTICAL
@@: @@:
test byte[esi + tga_header.image_spec.descriptor], TGA_START_RIGHT test byte[esi + tga_header.image_spec.descriptor], TGA_START_RIGHT
jz @f jz @f
or ebx, FLIP_HORIZONTAL or ebx, FLIP_HORIZONTAL
@@: @@:
test ebx, ebx test ebx, ebx
jz @f jz @f
stdcall img.flip, [retvalue], ebx stdcall img.flip, [retvalue], ebx
@@: @@:
pop edi esi ebx pop edi esi ebx
mov eax, [retvalue] mov eax, [retvalue]
ret ret
endp endp
;;================================================================================================;; ;;================================================================================================;;
proc img.encode.tga _img, _p_length, _options ;///////////////////////////////////////////////////;; proc img.encode.tga _img, _p_length, _options ;///////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;? Encode image into raw data in Targa format ;; ;? Encode image into raw data in Targa format ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;> _img = pointer to image ;; ;> _img = pointer to image ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) or pointer to encoded data ;; ;< eax = 0 (error) or pointer to encoded data ;;
;< _p_length = encoded data length ;; ;< _p_length = encoded data length ;;
;;================================================================================================;; ;;================================================================================================;;
xor eax, eax xor eax, eax
ret ret
endp endp
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;! Below are private procs you should never call directly from your code ;; ;! Below are private procs you should never call directly from your code ;;
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;! Below is private data you should never use directly from your code ;; ;! Below is private data you should never use directly from your code ;;
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;

View File

@@ -1,44 +1,44 @@
;;================================================================================================;; ;;================================================================================================;;
;;//// tga.inc //// (c) Nable, 2007-2008, (c) dunkaist, 2012 /////////////////////////////////////;; ;;//// tga.inc //// (c) Nable, 2007-2008, (c) dunkaist, 2012 /////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;; ;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;; ;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; ;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;; ;; of the License, or (at your option) any later version. ;;
;; ;; ;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; ;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; ;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;; ;; Lesser General Public License for more details. ;;
;; ;; ;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; ;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;; ;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
struct tga_colormap_spec struct tga_colormap_spec
first_entry_index dw ? first_entry_index dw ?
colormap_length dw ? colormap_length dw ?
entry_size db ? entry_size db ?
ends ends
struct tga_image_spec struct tga_image_spec
x_origin dw ? x_origin dw ?
y_origin dw ? y_origin dw ?
width dw ? width dw ?
height dw ? height dw ?
depth db ? depth db ?
descriptor db ? descriptor db ?
ends ends
struct tga_header struct tga_header
id_length db ? id_length db ?
colormap_type db ? colormap_type db ?
image_type db ? image_type db ?
colormap_spec tga_colormap_spec colormap_spec tga_colormap_spec
image_spec tga_image_spec image_spec tga_image_spec
ends ends
TGA_START_TOP = 0x20 TGA_START_TOP = 0x20
TGA_START_RIGHT = 0x10 TGA_START_RIGHT = 0x10

View File

@@ -29,10 +29,6 @@
include 'xcf.inc' include 'xcf.inc'
;include '../../../../../system/board/trunk/debug.inc' ;include '../../../../../system/board/trunk/debug.inc'
COMPOSITE_MODE equ MMX
; MMX | pretty fast and compatible
; SSE | a bit faster, but may be unsupported by some CPUs
MAX_LAYERS = 255 MAX_LAYERS = 255
;;================================================================================================;; ;;================================================================================================;;
@@ -1616,10 +1612,6 @@ endl
ret ret
endp endp
match =MMX, COMPOSITE_MODE{include 'composite_mmx.asm'}
match =SSE, COMPOSITE_MODE{include 'composite_sse.asm'}
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
@@ -1636,28 +1628,3 @@ xcf._.prop_table_begin:
dd 11, xcf._.parse_properties.11 dd 11, xcf._.parse_properties.11
dd 15, xcf._.parse_properties.15 dd 15, xcf._.parse_properties.15
xcf._.prop_table_end: xcf._.prop_table_end:
xcf._.composite_table.begin:
.p00 dd 00, xcf._.composite_rgb_00, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Normal
.p01 dd 01, xcf._.composite_rgb_01, xcf._.composite_gray_01, xcf._.composite_gray_01 ; Dissolve : random dithering to discrete alpha
; .p02 dd 02, xcf._.composite_rgb_02, 0, xcf._.composite_indexed_02 ; Behind : not selectable in the GIMP UI. not implemented
.p03 dd 03, xcf._.composite_rgb_03, xcf._.composite_rgb_03, xcf._.composite_indexed_00 ; Multiply
.p04 dd 04, xcf._.composite_rgb_04, xcf._.composite_rgb_04, xcf._.composite_indexed_00 ; Screen
.p05 dd 05, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Overlay
.p06 dd 06, xcf._.composite_rgb_06, xcf._.composite_rgb_06, xcf._.composite_indexed_00 ; Difference
.p07 dd 07, xcf._.composite_rgb_07, xcf._.composite_rgb_07, xcf._.composite_indexed_00 ; Addition
.p08 dd 08, xcf._.composite_rgb_08, xcf._.composite_rgb_08, xcf._.composite_indexed_00 ; Subtract
.p09 dd 09, xcf._.composite_rgb_09, xcf._.composite_rgb_09, xcf._.composite_indexed_00 ; Darken Only
.p10 dd 10, xcf._.composite_rgb_10, xcf._.composite_rgb_10, xcf._.composite_indexed_00 ; Lighten Only
.p11 dd 11, xcf._.composite_rgb_11, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Hue (H of HSV)
.p12 dd 12, xcf._.composite_rgb_12, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Saturation (S of HSV)
.p13 dd 13, xcf._.composite_rgb_13, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Color (H and S of HSL)
.p14 dd 14, xcf._.composite_rgb_14, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Value (V of HSV)
.p15 dd 15, xcf._.composite_rgb_15, xcf._.composite_rgb_15, xcf._.composite_indexed_00 ; Divide
.p16 dd 16, xcf._.composite_rgb_16, xcf._.composite_rgb_16, xcf._.composite_indexed_00 ; Dodge
.p17 dd 17, xcf._.composite_rgb_17, xcf._.composite_rgb_17, xcf._.composite_indexed_00 ; Burn
.p18 dd 18, xcf._.composite_rgb_18, xcf._.composite_rgb_18, xcf._.composite_indexed_00 ; Hard Light
.p19 dd 19, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Soft Light : XCF >= 2 only ('soft light' == 'overlay')
.p20 dd 20, xcf._.composite_rgb_20, xcf._.composite_rgb_20, xcf._.composite_indexed_00 ; Grain Extract : XCF >= 2 only
.p21 dd 21, xcf._.composite_rgb_21, xcf._.composite_rgb_21, xcf._.composite_indexed_00 ; Grain Merge : XCF >= 2 only
xcf._.composite_table.end:

View File

@@ -1,257 +1,257 @@
;;================================================================================================;; ;;================================================================================================;;
;;//// z80.asm //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;; ;;//// z80.asm //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;; ;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;; ;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; ;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;; ;; of the License, or (at your option) any later version. ;;
;; ;; ;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; ;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; ;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;; ;; Lesser General Public License for more details. ;;
;; ;; ;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; ;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;; ;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; References: ;; ;; References: ;;
;; 1. ;; ;; 1. ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
include 'z80.inc' include 'z80.inc'
;;================================================================================================;; ;;================================================================================================;;
proc img.is.z80 _data, _length ;//////////////////////////////////////////////////////////////////;; proc img.is.z80 _data, _length ;//////////////////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;? Determine if raw data could be decoded (is in z80 screen format) ;; ;? Determine if raw data could be decoded (is in z80 screen format) ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;> _data = raw data as read from file/stream ;; ;> _data = raw data as read from file/stream ;;
;> _length = data length ;; ;> _length = data length ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = false / true ;; ;< eax = false / true ;;
;;================================================================================================;; ;;================================================================================================;;
xor eax,eax xor eax,eax
cmp [_length],6929 cmp [_length],6929
setz al setz al
je @f je @f
cmp [_length],6912 cmp [_length],6912
setz al setz al
@@: @@:
ret ret
endp endp
;;================================================================================================;; ;;================================================================================================;;
proc img.decode.z80 _data, _length, _options ;////////////////////////////////////////////////////;; proc img.decode.z80 _data, _length, _options ;////////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;? Decode data into image if it contains correctly formed raw data in z80 screen format ;; ;? Decode data into image if it contains correctly formed raw data in z80 screen format ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;> _data = raw data as read from file/stream ;; ;> _data = raw data as read from file/stream ;;
;> _length = data length ;; ;> _length = data length ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) or pointer to image ;; ;< eax = 0 (error) or pointer to image ;;
;;================================================================================================;; ;;================================================================================================;;
;--------------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------------
;During the decoding: ;During the decoding:
;bl - PixelLeft (this means how much pixels left to put in current string) ;bl - PixelLeft (this means how much pixels left to put in current string)
;bh - CurrentString ;bh - CurrentString
;High half of ebx - use DualStos (two frames per one pixel_write) ;High half of ebx - use DualStos (two frames per one pixel_write)
;cl - PixelColorIndexInPalette ;cl - PixelColorIndexInPalette
;ch - BackgroundColorIndexInPalette ;ch - BackgroundColorIndexInPalette
;High half of ecx - blinking flag ;High half of ecx - blinking flag
;edx - address of current attribute byte ;edx - address of current attribute byte
;--------------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------------
locals locals
frame1 dd ? frame1 dd ?
OffsetIn2ndFrame dd ? OffsetIn2ndFrame dd ?
endl endl
xor eax,eax xor eax,eax
pushad pushad
cld ;paranoia cld ;paranoia
stdcall img.create,256,192,Image.bpp8i stdcall img.create,256,192,Image.bpp8i
test eax,eax test eax,eax
jz img.decode.z80.locret ;test if allocation failed jz img.decode.z80.locret ;test if allocation failed
mov [frame1],eax mov [frame1],eax
mov esi,z80._._16color_palette mov esi,z80._._16color_palette
mov ecx,16 mov ecx,16
mov edi,[eax+Image.Palette] mov edi,[eax+Image.Palette]
rep movsd ;write palette for the first frame rep movsd ;write palette for the first frame
mov esi,[_data] mov esi,[_data]
cmp [_length],6929 cmp [_length],6929
jne @f jne @f
add esi,17 ;in case of 6929 byte files we just skip the info in the begininning. add esi,17 ;in case of 6929 byte files we just skip the info in the begininning.
@@: @@:
;--------------------------------------------------------------------------------------------------- ;---------------------------------------------------------------------------------------------------
;At first we'll determine if there are any blinking pixels ;At first we'll determine if there are any blinking pixels
;if no - we'll produce statical single image ;if no - we'll produce statical single image
mov ecx,768 mov ecx,768
lea edx,[esi+6912-768];edx points to attribute area lea edx,[esi+6912-768];edx points to attribute area
xor ebx,ebx ;begin from <0,0> (for further decoding) xor ebx,ebx ;begin from <0,0> (for further decoding)
@@: @@:
test byte[edx+ecx-1],z80.BlinkFlag ;such addressing is a good optimisation test byte[edx+ecx-1],z80.BlinkFlag ;such addressing is a good optimisation
;(as I hope), edx is unchanged ;(as I hope), edx is unchanged
jnz .decode_z80_with_blinking jnz .decode_z80_with_blinking
loop @b loop @b
.decode_z80_without_blinking: .decode_z80_without_blinking:
jmp .decode_z80_main_stage jmp .decode_z80_main_stage
.decode_z80_with_blinking: .decode_z80_with_blinking:
or ebx,0xFFFF0000 ;use DualStos or ebx,0xFFFF0000 ;use DualStos
mov ecx,eax ;eax still points to the first frame mov ecx,eax ;eax still points to the first frame
stdcall img.create,256,192,Image.bpp8i stdcall img.create,256,192,Image.bpp8i
test eax,eax test eax,eax
jz img.decode.z80.failed jz img.decode.z80.failed
mov [eax+Image.Previous],ecx mov [eax+Image.Previous],ecx
mov [ecx+Image.Next],eax mov [ecx+Image.Next],eax
mov esi,z80._._16color_palette mov esi,z80._._16color_palette
mov ecx,16 mov ecx,16
mov edi,[eax+Image.Palette] mov edi,[eax+Image.Palette]
rep movsd ;write palette for the second frame rep movsd ;write palette for the second frame
mov eax,[eax+Image.Data] mov eax,[eax+Image.Data]
mov [OffsetIn2ndFrame],eax mov [OffsetIn2ndFrame],eax
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
.decode_z80_main_stage: .decode_z80_main_stage:
;2nd stage - convert z80 screen to 8bpp image with palette ;2nd stage - convert z80 screen to 8bpp image with palette
.decode_z80_main_stage_main_loop: .decode_z80_main_stage_main_loop:
test bl,7 test bl,7
jnz .decode_z80_main_stage_put_now jnz .decode_z80_main_stage_put_now
._z80_update_attributes: ._z80_update_attributes:
movsx ecx,byte[edx] ;note that BlinkFlag is the highest bit in attribute movsx ecx,byte[edx] ;note that BlinkFlag is the highest bit in attribute
;byte, so ecx's highest bit is set automatically ;byte, so ecx's highest bit is set automatically
shl ecx,5 shl ecx,5
shr cl,5 shr cl,5
and ch,0xF and ch,0xF
test ch,1000b test ch,1000b
jz @f jz @f
or ecx,1000b ;it has the same size with 'or cl,1000b' but could be faster or ecx,1000b ;it has the same size with 'or cl,1000b' but could be faster
@@: @@:
inc edx inc edx
lodsb lodsb
mov ah,al mov ah,al
.decode_z80_main_stage_put_now: .decode_z80_main_stage_put_now:
shl ah,1 shl ah,1
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
._z80_put_pixel: ._z80_put_pixel:
;In: CF - put pixel with color CL, !CF - pixel with color CH ;In: CF - put pixel with color CL, !CF - pixel with color CH
;High parts of ebx and ecx - as described above ;High parts of ebx and ecx - as described above
mov al,cl ;'mov' doesn't affect flags mov al,cl ;'mov' doesn't affect flags
jc @f jc @f
mov al,ch mov al,ch
@@: @@:
stosb ;'stosb' doesn't affect flags stosb ;'stosb' doesn't affect flags
test ebx,ebx test ebx,ebx
jns @f jns @f
test ecx,ecx test ecx,ecx
jns .1 jns .1
mov al,ch mov al,ch
.1: .1:
xchg [OffsetIn2ndFrame],edi xchg [OffsetIn2ndFrame],edi
stosb stosb
xchg [OffsetIn2ndFrame],edi xchg [OffsetIn2ndFrame],edi
@@: @@:
inc bl ;next pixel inc bl ;next pixel
jz .decode_z80_main_stage_row_finished jz .decode_z80_main_stage_row_finished
jmp .decode_z80_main_stage_main_loop jmp .decode_z80_main_stage_main_loop
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
.decode_z80_main_stage_row_finished: .decode_z80_main_stage_row_finished:
cmp bh,191 ;is image finished? cmp bh,191 ;is image finished?
jb .decode_z80_main_stage_image_not_finished ;no. jb .decode_z80_main_stage_image_not_finished ;no.
.decode_z80_finish: .decode_z80_finish:
jmp .locret ;now really finished jmp .locret ;now really finished
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
;or not finished yet. Branch according to a row number (see documentation) ;or not finished yet. Branch according to a row number (see documentation)
.decode_z80_main_stage_next_third: .decode_z80_main_stage_next_third:
sub bh,7 sub bh,7
sub edi,256*(8-1) sub edi,256*(8-1)
jmp .decode_z80_main_stage_main_loop jmp .decode_z80_main_stage_main_loop
.decode_z80_main_stage_image_not_finished: .decode_z80_main_stage_image_not_finished:
;next row ;next row
add bh,8 ;refer to documentation add bh,8 ;refer to documentation
add edi,256*(8-1) add edi,256*(8-1)
;if finished row is 63 or 127 then we process next third of the image ;if finished row is 63 or 127 then we process next third of the image
cmp bh,63+8 cmp bh,63+8
je .decode_z80_main_stage_next_third je .decode_z80_main_stage_next_third
cmp bh,127+8 cmp bh,127+8
je .decode_z80_main_stage_next_third je .decode_z80_main_stage_next_third
cmp bh,56+8 ;if finished row in [56;63) or [120;127) or [184;191) cmp bh,56+8 ;if finished row in [56;63) or [120;127) or [184;191)
jb .decode_z80_main_stage_main_loop jb .decode_z80_main_stage_main_loop
cmp bh,63+8 cmp bh,63+8
jb .4 jb .4
cmp bh,120+8 cmp bh,120+8
jb .decode_z80_main_stage_main_loop jb .decode_z80_main_stage_main_loop
cmp bh,127+8 cmp bh,127+8
jb .4 jb .4
cmp bh,184+8 cmp bh,184+8
jb .decode_z80_main_stage_main_loop jb .decode_z80_main_stage_main_loop
;note that if we are here then bh is < 191 (see label .2) but >= 184+8 ;note that if we are here then bh is < 191 (see label .2) but >= 184+8
.4: .4:
;and if we here then bh is in [56;63) or [120;127) or [184;191) ;and if we here then bh is in [56;63) or [120;127) or [184;191)
sub bh,(8+56-1) sub bh,(8+56-1)
sub edi,256*(8+56-1) sub edi,256*(8+56-1)
sub edx,z80.AttrString*8 sub edx,z80.AttrString*8
jmp .decode_z80_main_stage_main_loop jmp .decode_z80_main_stage_main_loop
img.decode.z80.locret: img.decode.z80.locret:
popad popad
ret ret
img.decode.z80.failed: img.decode.z80.failed:
stdcall img.destroy,[frame1] stdcall img.destroy,[frame1]
jmp img.decode.z80.locret jmp img.decode.z80.locret
endp endp
;;================================================================================================;; ;;================================================================================================;;
proc img.encode.z80 _img, _p_length, _options ;///////////////////////////////////////////////////;; proc img.encode.z80 _img, _p_length, _options ;///////////////////////////////////////////////////;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;? Encode image into raw data in z80 screen format ;; ;? Encode image into raw data in z80 screen format ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;> _img = pointer to image ;; ;> _img = pointer to image ;;
;;------------------------------------------------------------------------------------------------;; ;;------------------------------------------------------------------------------------------------;;
;< eax = 0 (error) or pointer to encoded data ;; ;< eax = 0 (error) or pointer to encoded data ;;
;< _p_length = encoded data length ;; ;< _p_length = encoded data length ;;
;;================================================================================================;; ;;================================================================================================;;
xor eax, eax xor eax, eax
ret ret
endp endp
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;! Below are private procs you should never call directly from your code ;; ;! Below are private procs you should never call directly from your code ;;
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;! Below is private data you should never use directly from your code ;; ;! Below is private data you should never use directly from your code ;;
;;================================================================================================;; ;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
z80._._16color_palette: z80._._16color_palette:
dd 0 ; black dd 0 ; black
dd 0x000000b0 ; blue dd 0x000000b0 ; blue
dd 0x00b00000 ; red dd 0x00b00000 ; red
dd 0x00b000b0 ; magenta dd 0x00b000b0 ; magenta
dd 0x0000b000 ; green dd 0x0000b000 ; green
dd 0x0000b0b0 ; cyan dd 0x0000b0b0 ; cyan
dd 0x00b0b000 ; yellow dd 0x00b0b000 ; yellow
dd 0x00b0b0b0 ; gray dd 0x00b0b0b0 ; gray
dd 0 ; black dd 0 ; black
dd 0x000000ff ; light blue dd 0x000000ff ; light blue
dd 0x00ff0000 ; light red dd 0x00ff0000 ; light red
dd 0x00ff00ff ; light magenta dd 0x00ff00ff ; light magenta
dd 0x0000ff00 ; light green dd 0x0000ff00 ; light green
dd 0x0000ffff ; light cyan dd 0x0000ffff ; light cyan
dd 0x00ffff00 ; light yellow dd 0x00ffff00 ; light yellow
dd 0x00ffffff ; white dd 0x00ffffff ; white

View File

@@ -1,23 +1,23 @@
;;================================================================================================;; ;;================================================================================================;;
;;//// z80.inc //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;; ;;//// z80.inc //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;;
;;================================================================================================;; ;;================================================================================================;;
;; ;; ;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;; ;; This file is part of Common development libraries (Libs-Dev). ;;
;; ;; ;; ;;
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; ;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; ;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;;
;; of the License, or (at your option) any later version. ;; ;; of the License, or (at your option) any later version. ;;
;; ;; ;; ;;
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; ;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; ;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
;; Lesser General Public License for more details. ;; ;; Lesser General Public License for more details. ;;
;; ;; ;; ;;
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; ;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;;
;; If not, see <http://www.gnu.org/licenses/>. ;; ;; If not, see <http://www.gnu.org/licenses/>. ;;
;; ;; ;; ;;
;;================================================================================================;; ;;================================================================================================;;
z80.PixColor equ 000111b z80.PixColor equ 000111b
z80.BgrColor equ 111000b z80.BgrColor equ 111000b
z80.BrightFlag equ (1 shl 6) z80.BrightFlag equ (1 shl 6)
z80.BlinkFlag equ (1 shl 7) z80.BlinkFlag equ (1 shl 7)
z80.AttrString equ 32 z80.AttrString equ 32