forked from KolibriOS/kolibrios
libimg: Add and export img.blend function
git-svn-id: svn://kolibrios.org@8341 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
54712199cb
commit
263f2855f2
@ -1,2 +1,6 @@
|
||||
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")
|
||||
|
76
programs/develop/libraries/libs-dev/libimg/blend.asm
Normal file
76
programs/develop/libraries/libs-dev/libimg/blend.asm
Normal 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:
|
@ -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
|
||||
|
||||
xchg al, bh
|
@ -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
|
||||
|
||||
push eax ebx
|
File diff suppressed because it is too large
Load Diff
@ -1,107 +1,107 @@
|
||||
;;================================================================================================;;
|
||||
;;//// bmp.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
|
||||
struct bmp.FileHeader
|
||||
Type dw ? ; File type, always 4D42h ("BM")
|
||||
Size dd ? ; Size of the file in bytes
|
||||
dw 2 dup(?) ; Reserved; must be set to zero.
|
||||
OffBits dd ? ; Starting position of image data in bytes
|
||||
ends
|
||||
|
||||
struct bmp.InfoHeader
|
||||
; v2 (Windows 2.x)
|
||||
Size dd ? ; Size of this header in bytes
|
||||
union
|
||||
struct ; new format
|
||||
Width dd ? ; Image width in pixels
|
||||
Height dd ? ; Image height in pixels
|
||||
Planes dw ? ; Number of color planes
|
||||
BitCount dw ? ; Number of bits per pixel
|
||||
ends
|
||||
struct ; old format
|
||||
OldWidth dw ? ; Image width in pixels as word
|
||||
OldHeight dw ? ; Image height in pixels as word
|
||||
OldPlanes dw ? ; Number of color planes
|
||||
OldBitCount dw ? ; Number of bits per pixel
|
||||
ends
|
||||
ends
|
||||
; v3 (Windows 3.x)
|
||||
Compression dd ? ; Compression method used
|
||||
SizeImage dd ? ; Size of bitmap in bytes
|
||||
XPelsPerMeter dd ? ; Horizontal resolution in pixels per meter
|
||||
YPelsPerMeter dd ? ; Vertical resolution in pixels per meter
|
||||
ClrUsed dd ? ; Number of colors in the image
|
||||
ClrImportant dd ? ; Minimum number of important colors
|
||||
union
|
||||
Palette dd ? ; Image palette if BitCount in [1,4,8]
|
||||
; v4 (Windows 95)
|
||||
struct
|
||||
RedMask dd ? ; Mask identifying bits of red component
|
||||
GreenMask dd ? ; Mask identifying bits of green component
|
||||
BlueMask dd ? ; Mask identifying bits of blue component
|
||||
AlphaMask dd ? ; Mask identifying bits of alpha component
|
||||
CSType dd ? ; Color space type
|
||||
RedX dd ? ; X coordinate of red endpoint
|
||||
RedY dd ? ; Y coordinate of red endpoint
|
||||
RedZ dd ? ; Z coordinate of red endpoint
|
||||
GreenX dd ? ; X coordinate of green endpoint
|
||||
GreenY dd ? ; Y coordinate of green endpoint
|
||||
GreenZ dd ? ; Z coordinate of green endpoint
|
||||
BlueX dd ? ; X coordinate of blue endpoint
|
||||
BlueY dd ? ; Y coordinate of blue endpoint
|
||||
BlueZ dd ? ; Z coordinate of blue endpoint
|
||||
GammaRed dd ? ; Gamma red coordinate scale value
|
||||
GammaGreen dd ? ; Gamma green coordinate scale value
|
||||
GammaBlue dd ? ; Gamma blue coordinate scale value
|
||||
ends
|
||||
ends
|
||||
ends
|
||||
|
||||
define bmp.BI_RGB 0
|
||||
define bmp.BI_RLE8 1
|
||||
define bmp.BI_RLE4 2
|
||||
define bmp.BI_BITFIELDS 3
|
||||
define bmp.BI_JPEG 4
|
||||
define bmp.BI_PNG 5
|
||||
|
||||
struct bmp.Header
|
||||
file bmp.FileHeader
|
||||
info bmp.InfoHeader
|
||||
ends
|
||||
|
||||
struct bmp.RgbByteQuad
|
||||
Red db ?
|
||||
Green db ?
|
||||
Blue db ?
|
||||
Alpha db ?
|
||||
ends
|
||||
|
||||
struct bmp.RgbQuad
|
||||
Red dd ?
|
||||
Green dd ?
|
||||
Blue dd ?
|
||||
Alpha dd ?
|
||||
ends
|
||||
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
|
||||
struct bmp.Image
|
||||
info bmp.InfoHeader
|
||||
ends
|
||||
;;================================================================================================;;
|
||||
;;//// bmp.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
|
||||
struct bmp.FileHeader
|
||||
Type dw ? ; File type, always 4D42h ("BM")
|
||||
Size dd ? ; Size of the file in bytes
|
||||
dw 2 dup(?) ; Reserved; must be set to zero.
|
||||
OffBits dd ? ; Starting position of image data in bytes
|
||||
ends
|
||||
|
||||
struct bmp.InfoHeader
|
||||
; v2 (Windows 2.x)
|
||||
Size dd ? ; Size of this header in bytes
|
||||
union
|
||||
struct ; new format
|
||||
Width dd ? ; Image width in pixels
|
||||
Height dd ? ; Image height in pixels
|
||||
Planes dw ? ; Number of color planes
|
||||
BitCount dw ? ; Number of bits per pixel
|
||||
ends
|
||||
struct ; old format
|
||||
OldWidth dw ? ; Image width in pixels as word
|
||||
OldHeight dw ? ; Image height in pixels as word
|
||||
OldPlanes dw ? ; Number of color planes
|
||||
OldBitCount dw ? ; Number of bits per pixel
|
||||
ends
|
||||
ends
|
||||
; v3 (Windows 3.x)
|
||||
Compression dd ? ; Compression method used
|
||||
SizeImage dd ? ; Size of bitmap in bytes
|
||||
XPelsPerMeter dd ? ; Horizontal resolution in pixels per meter
|
||||
YPelsPerMeter dd ? ; Vertical resolution in pixels per meter
|
||||
ClrUsed dd ? ; Number of colors in the image
|
||||
ClrImportant dd ? ; Minimum number of important colors
|
||||
union
|
||||
Palette dd ? ; Image palette if BitCount in [1,4,8]
|
||||
; v4 (Windows 95)
|
||||
struct
|
||||
RedMask dd ? ; Mask identifying bits of red component
|
||||
GreenMask dd ? ; Mask identifying bits of green component
|
||||
BlueMask dd ? ; Mask identifying bits of blue component
|
||||
AlphaMask dd ? ; Mask identifying bits of alpha component
|
||||
CSType dd ? ; Color space type
|
||||
RedX dd ? ; X coordinate of red endpoint
|
||||
RedY dd ? ; Y coordinate of red endpoint
|
||||
RedZ dd ? ; Z coordinate of red endpoint
|
||||
GreenX dd ? ; X coordinate of green endpoint
|
||||
GreenY dd ? ; Y coordinate of green endpoint
|
||||
GreenZ dd ? ; Z coordinate of green endpoint
|
||||
BlueX dd ? ; X coordinate of blue endpoint
|
||||
BlueY dd ? ; Y coordinate of blue endpoint
|
||||
BlueZ dd ? ; Z coordinate of blue endpoint
|
||||
GammaRed dd ? ; Gamma red coordinate scale value
|
||||
GammaGreen dd ? ; Gamma green coordinate scale value
|
||||
GammaBlue dd ? ; Gamma blue coordinate scale value
|
||||
ends
|
||||
ends
|
||||
ends
|
||||
|
||||
define bmp.BI_RGB 0
|
||||
define bmp.BI_RLE8 1
|
||||
define bmp.BI_RLE4 2
|
||||
define bmp.BI_BITFIELDS 3
|
||||
define bmp.BI_JPEG 4
|
||||
define bmp.BI_PNG 5
|
||||
|
||||
struct bmp.Header
|
||||
file bmp.FileHeader
|
||||
info bmp.InfoHeader
|
||||
ends
|
||||
|
||||
struct bmp.RgbByteQuad
|
||||
Red db ?
|
||||
Green db ?
|
||||
Blue db ?
|
||||
Alpha db ?
|
||||
ends
|
||||
|
||||
struct bmp.RgbQuad
|
||||
Red dd ?
|
||||
Green dd ?
|
||||
Blue dd ?
|
||||
Alpha dd ?
|
||||
ends
|
||||
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
|
||||
struct bmp.Image
|
||||
info bmp.InfoHeader
|
||||
ends
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,142 +1,142 @@
|
||||
;;================================================================================================;;
|
||||
;;//// gif.inc //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
|
||||
struct gif.FileHeader ; GIF87a
|
||||
Signature db 3 dup(?) ; Header Signature (always "GIF")
|
||||
Version db 3 dup(?) ; GIF format version("87a" or "89a")
|
||||
ends
|
||||
|
||||
struct gif.LogicalScreenDescriptor ; GIF87a
|
||||
ScreenWidth dw ? ; Width of Display Screen in Pixels
|
||||
ScreenHeight dw ? ; Height of Display Screen in Pixels
|
||||
Packed db ? ; Screen and Color Map Information
|
||||
BackgroundColor db ? ; Background Color Index
|
||||
AspectRatio db ? ; Pixel Aspect Ratio
|
||||
ends
|
||||
|
||||
gif.LSD.Packed.SizeOfGlobalColorTableMask = 000000111b
|
||||
gif.LSD.Packed.SizeOfGlobalColorTableShift = 0
|
||||
gif.LSD.Packed.ColorTableSortFlag = 000001000b
|
||||
gif.LSD.Packed.ColorTableSortShift = 3
|
||||
gif.LSD.Packed.ColorResolutionMask = 001110000b
|
||||
gif.LSD.Packed.ColorResolutionShift = 4
|
||||
gif.LSD.Packed.GlobalColorTableFlag = 010000000b
|
||||
gif.LSD.Packed.GlobalColorTableShift = 7
|
||||
|
||||
struct gif.Header
|
||||
file gif.FileHeader
|
||||
lsd gif.LogicalScreenDescriptor
|
||||
ends
|
||||
|
||||
struct gif.RgbTriplet ; GIF87a
|
||||
Red db ? ; Red Color Element
|
||||
Green db ? ; Green Color Element
|
||||
Blue db ? ; Blue Color Element
|
||||
ends
|
||||
|
||||
struct gif.Block
|
||||
Introducer db ?
|
||||
ends
|
||||
|
||||
gif.Block.Introducer.EndOfData = 0x00
|
||||
gif.Block.Introducer.Extension = 0x21
|
||||
gif.Block.Introducer.ImageDescriptor = 0x2C
|
||||
gif.Block.Introducer.EndOfFile = 0x3B
|
||||
|
||||
struct gif.ImageDescriptor ; GIF87a
|
||||
; we read Introducer before parsing gif.ImageDescriptor,
|
||||
; so it is convenient to not include it in struct
|
||||
; b gif.Block ; Introducer = 2Ch (',')
|
||||
Left dw ? ; X position of image on the display
|
||||
Top dw ? ; Y position of image on the display
|
||||
Width dw ? ; Width of the image in pixels
|
||||
Height dw ? ; Height of the image in pixels
|
||||
Packed db ? ; Image and Color Table Data Information
|
||||
ends
|
||||
|
||||
gif.ID.Packed.SizeOfLocalColorTableMask = 000000111b
|
||||
gif.ID.Packed.SizeOfLocalColorTableShift = 0
|
||||
gif.ID.Packed.SortFlag = 000100000b
|
||||
gif.ID.Packed.SortShift = 5
|
||||
gif.ID.Packed.InterleaceFlag = 001000000b
|
||||
gif.ID.Packed.InterleaceShift = 6
|
||||
gif.ID.Packed.LocalColorTableFlag = 010000000b
|
||||
gif.ID.Packed.LocalColorTableShift = 7
|
||||
|
||||
struct gif.Extension
|
||||
b gif.Block ; Introducer = 21h ('|')
|
||||
Label db ? ; Extension label
|
||||
ends
|
||||
|
||||
gif.Extension.Label.PlainText = 0x01
|
||||
gif.Extension.Label.GraphicsControl = 0xF9
|
||||
gif.Extension.Label.Comment = 0xFE
|
||||
gif.Extension.Label.Application = 0xFF
|
||||
|
||||
struct gif.PlainTextExtension ; GIF89a
|
||||
; e gif.Extension ; Label = 01h
|
||||
; BlockSize db ? ; Size of Extension Block (always 0Ch)
|
||||
TextGridLeft dw ? ; X position of text grid in pixels
|
||||
TextGridTop dw ? ; Y position of text grid in pixels
|
||||
TextGridWidth dw ? ; Width of the text grid in pixels
|
||||
TextGridHeight dw ? ; Height of the text grid in pixels
|
||||
CellWidth db ? ; Width of a grid cell in pixels
|
||||
CellHeight db ? ; Height of a grid cell in pixels
|
||||
TextFgColorIndex db ? ; Text foreground color index value
|
||||
TextBgColorIndex db ? ; Text background color index value
|
||||
PlainTextData db ? ; The Plain Text data (*)
|
||||
; Terminator db ? ; Block Terminator (always 0)
|
||||
ends
|
||||
|
||||
struct gif.GraphicsControlExtension ; GIF89a
|
||||
; e gif.Extension ; Label = F9h
|
||||
; BlockSize db ? ; Size of remaining fields (always 04h)
|
||||
; previous fields are not included in this structure for convenience
|
||||
; (they are parsed before this)
|
||||
Packed db ? ; Method of graphics disposal to use
|
||||
DelayTime dw ? ; Hundredths of seconds to wait
|
||||
ColorIndex db ? ; Transparent Color Index
|
||||
; Terminator db ? ; Block Terminator (always 0)
|
||||
ends
|
||||
|
||||
struct gif.CommentExtension ; GIF89a
|
||||
e gif.Extension ; Label = FEh
|
||||
CommentData db ? ; Pointer to Comment Data sub-blocks (*)
|
||||
; Terminator db ? ; Block Terminator (always 0)
|
||||
ends
|
||||
|
||||
struct gif.ApplicationExtension ; GIF89a
|
||||
e gif.Extension ; Label = FFh
|
||||
BlockSize db ? ; Size of Extension Block (always 0Bh)
|
||||
Identifier db 8 dup(?) ; Application Identifier
|
||||
AuthentCode db 3 dup(?) ; Application Authentication Code
|
||||
ApplicationData db ? ; Point to Application Data sub-blocks (*)
|
||||
; Terminator db ? ; Block Terminator (always 0)
|
||||
ends
|
||||
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
|
||||
struct gif.Image
|
||||
info gif.ImageDescriptor
|
||||
gce gif.GraphicsControlExtension
|
||||
; lsd gif.LogicalScreenDescriptor ; saved only in first image
|
||||
ends
|
||||
|
||||
gif.Null equ 0x1000
|
||||
;;================================================================================================;;
|
||||
;;//// gif.inc //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
|
||||
struct gif.FileHeader ; GIF87a
|
||||
Signature db 3 dup(?) ; Header Signature (always "GIF")
|
||||
Version db 3 dup(?) ; GIF format version("87a" or "89a")
|
||||
ends
|
||||
|
||||
struct gif.LogicalScreenDescriptor ; GIF87a
|
||||
ScreenWidth dw ? ; Width of Display Screen in Pixels
|
||||
ScreenHeight dw ? ; Height of Display Screen in Pixels
|
||||
Packed db ? ; Screen and Color Map Information
|
||||
BackgroundColor db ? ; Background Color Index
|
||||
AspectRatio db ? ; Pixel Aspect Ratio
|
||||
ends
|
||||
|
||||
gif.LSD.Packed.SizeOfGlobalColorTableMask = 000000111b
|
||||
gif.LSD.Packed.SizeOfGlobalColorTableShift = 0
|
||||
gif.LSD.Packed.ColorTableSortFlag = 000001000b
|
||||
gif.LSD.Packed.ColorTableSortShift = 3
|
||||
gif.LSD.Packed.ColorResolutionMask = 001110000b
|
||||
gif.LSD.Packed.ColorResolutionShift = 4
|
||||
gif.LSD.Packed.GlobalColorTableFlag = 010000000b
|
||||
gif.LSD.Packed.GlobalColorTableShift = 7
|
||||
|
||||
struct gif.Header
|
||||
file gif.FileHeader
|
||||
lsd gif.LogicalScreenDescriptor
|
||||
ends
|
||||
|
||||
struct gif.RgbTriplet ; GIF87a
|
||||
Red db ? ; Red Color Element
|
||||
Green db ? ; Green Color Element
|
||||
Blue db ? ; Blue Color Element
|
||||
ends
|
||||
|
||||
struct gif.Block
|
||||
Introducer db ?
|
||||
ends
|
||||
|
||||
gif.Block.Introducer.EndOfData = 0x00
|
||||
gif.Block.Introducer.Extension = 0x21
|
||||
gif.Block.Introducer.ImageDescriptor = 0x2C
|
||||
gif.Block.Introducer.EndOfFile = 0x3B
|
||||
|
||||
struct gif.ImageDescriptor ; GIF87a
|
||||
; we read Introducer before parsing gif.ImageDescriptor,
|
||||
; so it is convenient to not include it in struct
|
||||
; b gif.Block ; Introducer = 2Ch (',')
|
||||
Left dw ? ; X position of image on the display
|
||||
Top dw ? ; Y position of image on the display
|
||||
Width dw ? ; Width of the image in pixels
|
||||
Height dw ? ; Height of the image in pixels
|
||||
Packed db ? ; Image and Color Table Data Information
|
||||
ends
|
||||
|
||||
gif.ID.Packed.SizeOfLocalColorTableMask = 000000111b
|
||||
gif.ID.Packed.SizeOfLocalColorTableShift = 0
|
||||
gif.ID.Packed.SortFlag = 000100000b
|
||||
gif.ID.Packed.SortShift = 5
|
||||
gif.ID.Packed.InterleaceFlag = 001000000b
|
||||
gif.ID.Packed.InterleaceShift = 6
|
||||
gif.ID.Packed.LocalColorTableFlag = 010000000b
|
||||
gif.ID.Packed.LocalColorTableShift = 7
|
||||
|
||||
struct gif.Extension
|
||||
b gif.Block ; Introducer = 21h ('|')
|
||||
Label db ? ; Extension label
|
||||
ends
|
||||
|
||||
gif.Extension.Label.PlainText = 0x01
|
||||
gif.Extension.Label.GraphicsControl = 0xF9
|
||||
gif.Extension.Label.Comment = 0xFE
|
||||
gif.Extension.Label.Application = 0xFF
|
||||
|
||||
struct gif.PlainTextExtension ; GIF89a
|
||||
; e gif.Extension ; Label = 01h
|
||||
; BlockSize db ? ; Size of Extension Block (always 0Ch)
|
||||
TextGridLeft dw ? ; X position of text grid in pixels
|
||||
TextGridTop dw ? ; Y position of text grid in pixels
|
||||
TextGridWidth dw ? ; Width of the text grid in pixels
|
||||
TextGridHeight dw ? ; Height of the text grid in pixels
|
||||
CellWidth db ? ; Width of a grid cell in pixels
|
||||
CellHeight db ? ; Height of a grid cell in pixels
|
||||
TextFgColorIndex db ? ; Text foreground color index value
|
||||
TextBgColorIndex db ? ; Text background color index value
|
||||
PlainTextData db ? ; The Plain Text data (*)
|
||||
; Terminator db ? ; Block Terminator (always 0)
|
||||
ends
|
||||
|
||||
struct gif.GraphicsControlExtension ; GIF89a
|
||||
; e gif.Extension ; Label = F9h
|
||||
; BlockSize db ? ; Size of remaining fields (always 04h)
|
||||
; previous fields are not included in this structure for convenience
|
||||
; (they are parsed before this)
|
||||
Packed db ? ; Method of graphics disposal to use
|
||||
DelayTime dw ? ; Hundredths of seconds to wait
|
||||
ColorIndex db ? ; Transparent Color Index
|
||||
; Terminator db ? ; Block Terminator (always 0)
|
||||
ends
|
||||
|
||||
struct gif.CommentExtension ; GIF89a
|
||||
e gif.Extension ; Label = FEh
|
||||
CommentData db ? ; Pointer to Comment Data sub-blocks (*)
|
||||
; Terminator db ? ; Block Terminator (always 0)
|
||||
ends
|
||||
|
||||
struct gif.ApplicationExtension ; GIF89a
|
||||
e gif.Extension ; Label = FFh
|
||||
BlockSize db ? ; Size of Extension Block (always 0Bh)
|
||||
Identifier db 8 dup(?) ; Application Identifier
|
||||
AuthentCode db 3 dup(?) ; Application Authentication Code
|
||||
ApplicationData db ? ; Point to Application Data sub-blocks (*)
|
||||
; Terminator db ? ; Block Terminator (always 0)
|
||||
ends
|
||||
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
|
||||
struct gif.Image
|
||||
info gif.ImageDescriptor
|
||||
gce gif.GraphicsControlExtension
|
||||
; lsd gif.LogicalScreenDescriptor ; saved only in first image
|
||||
ends
|
||||
|
||||
gif.Null equ 0x1000
|
||||
|
@ -1,372 +1,372 @@
|
||||
;;================================================================================================;;
|
||||
;;//// ico.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; References: ;;
|
||||
;; 1. "Icons in Win32" ;;
|
||||
;; by John Hornick, Microsoft Corporation ;;
|
||||
;; http://msdn2.microsoft.com/en-us/library/ms997538.aspx ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
include 'ico_cur.inc'
|
||||
|
||||
;;================================================================================================;;
|
||||
;;proc img.is.ico _data, _length ;////////////////////////////////////////////////////////////////;;
|
||||
img.is.ico:
|
||||
mov edx, 0x00010000 ; icon type = 1
|
||||
jmp @f
|
||||
img.is.cur:
|
||||
mov edx, 0x00020000 ; cursor type = 2
|
||||
@@:
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Determine if raw data could be decoded (is in ICO format) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = false / true ;;
|
||||
;;================================================================================================;;
|
||||
; test 1 (length of data): data must contain FileHeader
|
||||
mov ecx, [esp+8]
|
||||
sub ecx, sizeof.ico.FileHeader
|
||||
jb .nope
|
||||
; test 2: signature
|
||||
mov eax, [esp+4]
|
||||
cmp dword [eax], edx ; Reserved & Type
|
||||
jne .nope
|
||||
; test 3: count must be non-zero
|
||||
movzx eax, [eax + ico.FileHeader.Count]
|
||||
test eax, eax
|
||||
jz .nope
|
||||
; test 4 (length of data): data must containt Count dir entries
|
||||
shl eax, 4
|
||||
sub ecx, eax
|
||||
jae .yep
|
||||
|
||||
.nope:
|
||||
xor eax, eax
|
||||
ret 8
|
||||
|
||||
.yep:
|
||||
xor eax, eax
|
||||
inc eax
|
||||
ret 8
|
||||
;endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.ico_cur _data, _length, _options ;////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in ICO/CUR format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;> _options = options for decoding (e.g. background color) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
locals
|
||||
count dd ?
|
||||
img dd ?
|
||||
main_img dd ?
|
||||
endl
|
||||
|
||||
push ebx esi edi
|
||||
|
||||
; img.is.ico has been already called by img.decode
|
||||
; stdcall img.is.ico, [_data], [_length]
|
||||
; or eax, eax
|
||||
; jz .error
|
||||
|
||||
mov ebx, [_data]
|
||||
movzx eax, [ebx + ico.FileHeader.Count]
|
||||
mov [count], eax
|
||||
and [img], 0
|
||||
and [main_img], 0
|
||||
.loop:
|
||||
mov ecx, [ebx + sizeof.ico.FileHeader + ico.DirEntry.ByteSize]
|
||||
mov edx, [ebx + sizeof.ico.FileHeader + ico.DirEntry.ImageOffset]
|
||||
mov eax, [_length]
|
||||
sub eax, edx
|
||||
jb .skip
|
||||
cmp eax, ecx
|
||||
jb .skip
|
||||
cmp ecx, 12 ; length test, see img.is.bmp
|
||||
jb .skip
|
||||
add edx, [_data]
|
||||
push [_options]
|
||||
push ecx
|
||||
push edx
|
||||
call img.decode.ico._.decode_icon_data
|
||||
test eax, eax
|
||||
jz .skip
|
||||
push 0xFFFFFF ; set bgr to white if no given
|
||||
mov edx, [_options]
|
||||
test edx, edx
|
||||
jz @f
|
||||
cmp [edx + ImageDecodeOptions.UsedSize], ImageDecodeOptions.BackgroundColor + 4
|
||||
jb @f
|
||||
add esp, 4
|
||||
push [edx + ImageDecodeOptions.BackgroundColor]
|
||||
@@:
|
||||
call img.decode.ico._.decode_icon_mask
|
||||
test eax, eax
|
||||
jz .skip
|
||||
mov edx, [img]
|
||||
test edx, edx
|
||||
jz .first
|
||||
mov [edx + Image.Next], eax
|
||||
mov [eax + Image.Previous], edx
|
||||
jmp @f
|
||||
.first:
|
||||
mov [main_img], eax
|
||||
@@:
|
||||
mov [img], eax
|
||||
.skip:
|
||||
add ebx, sizeof.ico.DirEntry
|
||||
dec [count]
|
||||
jnz .loop
|
||||
|
||||
mov eax, [main_img]
|
||||
pop edi esi ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
img.encode.cur:
|
||||
proc img.encode.ico _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in ICO format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _img = pointer to image ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to encoded data ;;
|
||||
;< _p_length = encoded data length ;;
|
||||
;;================================================================================================;;
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below are private procs you should never call directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
img.decode.ico._.decode_icon_data:
|
||||
; create stack frame and jump to common BMP+ICO code
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
sub esp, 12
|
||||
mov byte [ebp - 3], 1 ; bIsIco
|
||||
jmp img.decode.bmp.common
|
||||
|
||||
img.decode.ico._.decode_icon_mask:
|
||||
mov edx, [eax + Image.Width]
|
||||
add edx, 31
|
||||
shr edx, 3
|
||||
and edx, not 3
|
||||
push edx
|
||||
imul edx, [eax + Image.Height]
|
||||
cmp ecx, edx
|
||||
pop edx
|
||||
jb .error.free
|
||||
mov edi, [eax + Image.Data]
|
||||
push ebp ebx eax
|
||||
xor ebp, ebp
|
||||
mov ebx, [eax + Image.Extended]
|
||||
cmp [ebx + bmp.Image.info.Height], 0
|
||||
js @f
|
||||
push edx
|
||||
imul edx, [eax + Image.Height]
|
||||
add esi, edx
|
||||
pop edx
|
||||
lea ebp, [edx+edx]
|
||||
sub esi, edx
|
||||
@@:
|
||||
mov ebx, [eax + Image.Height]
|
||||
mov ecx, [eax + Image.Width]
|
||||
; for now, BMP code produces only 8 and 32 bpp images
|
||||
cmp [eax + Image.Type], Image.bpp8i
|
||||
jz .bpp8
|
||||
.bpp32:
|
||||
mov edx, [esp+16] ; get background color
|
||||
.bpp32.extloop:
|
||||
push ecx
|
||||
.bpp32.innloop:
|
||||
lodsd
|
||||
bswap eax
|
||||
push 32
|
||||
.bpp32.dwordloop:
|
||||
add eax, eax
|
||||
jnc @f
|
||||
mov [edi], edx
|
||||
@@:
|
||||
add edi, 4
|
||||
dec ecx
|
||||
jz @f
|
||||
dec dword [esp]
|
||||
jnz .bpp32.dwordloop
|
||||
@@:
|
||||
pop eax
|
||||
test ecx, ecx
|
||||
jnz .bpp32.innloop
|
||||
sub esi, ebp
|
||||
pop ecx
|
||||
dec ebx
|
||||
jnz .bpp32.extloop
|
||||
pop eax ebx ebp
|
||||
ret 4
|
||||
.bpp8:
|
||||
push edi
|
||||
mov edi, [eax + Image.Palette]
|
||||
mov eax, [esp+20] ; get background color
|
||||
; if palette already has index for bgr color, use it
|
||||
push ecx
|
||||
mov ecx, 256
|
||||
repnz scasd
|
||||
jnz .bpp8.notfound
|
||||
not cl ; cl = index
|
||||
pop edx
|
||||
pop edi
|
||||
.bpp8.extloop:
|
||||
push edx
|
||||
.bpp8.innloop:
|
||||
lodsd
|
||||
bswap eax
|
||||
push 32
|
||||
.bpp8.dwordloop:
|
||||
add eax, eax
|
||||
jnc @f
|
||||
mov [edi], cl
|
||||
@@:
|
||||
inc edi
|
||||
dec edx
|
||||
jz @f
|
||||
dec dword [esp]
|
||||
jnz .bpp8.dwordloop
|
||||
@@:
|
||||
pop eax
|
||||
test edx, edx
|
||||
jnz .bpp8.innloop
|
||||
sub esi, ebp
|
||||
pop edx
|
||||
dec ebx
|
||||
jnz .bpp8.extloop
|
||||
pop eax ebx ebp
|
||||
ret 4
|
||||
.bpp8.notfound:
|
||||
; get maximum used color; if index < 255, then we can add one color to palette
|
||||
pop ecx
|
||||
pop edi
|
||||
pop eax
|
||||
mov edx, [eax + Image.Width]
|
||||
imul edx, ebx
|
||||
mov edi, [eax + Image.Data]
|
||||
xor ecx, ecx
|
||||
.bpp8.scanloop:
|
||||
cmp [edi], cl
|
||||
jb @f
|
||||
mov cl, [edi]
|
||||
@@:
|
||||
inc edi
|
||||
dec edx
|
||||
jnz .bpp8.scanloop
|
||||
inc cl
|
||||
jz .bpp8.nospace
|
||||
mov edx, [esp+8]
|
||||
mov edi, [eax + Image.Palette]
|
||||
mov [edi+ecx*4], edx ; set palette color
|
||||
mov edi, [eax + Image.Data]
|
||||
mov edx, [eax + Image.Width]
|
||||
push eax
|
||||
jmp .bpp8.extloop
|
||||
.bpp8.nospace:
|
||||
; convert to 24 bpp
|
||||
mov edx, [eax + Image.Width]
|
||||
imul edx, ebx
|
||||
lea edx, [edx*3]
|
||||
push eax
|
||||
invoke mem.alloc, edx
|
||||
mov edi, eax
|
||||
pop eax
|
||||
test edi, edi
|
||||
jz .error.free2
|
||||
push eax esi edi
|
||||
mov esi, eax
|
||||
call img._.do_rgb
|
||||
pop edi esi eax
|
||||
xchg edi, [eax + Image.Data]
|
||||
mov byte [eax + Image.Type], Image.bpp24
|
||||
push eax
|
||||
invoke mem.free, edi
|
||||
pop eax
|
||||
push eax
|
||||
mov ecx, [eax + Image.Width]
|
||||
mov edi, [eax + Image.Data]
|
||||
.bpp24:
|
||||
mov edx, [esp+16] ; get background color
|
||||
.bpp24.extloop:
|
||||
push ecx
|
||||
.bpp24.innloop:
|
||||
lodsd
|
||||
bswap eax
|
||||
push 32
|
||||
.bpp24.dwordloop:
|
||||
add eax, eax
|
||||
jnc @f
|
||||
mov [edi], dx
|
||||
ror edx, 16
|
||||
mov [edi+2], dl
|
||||
ror edx, 16
|
||||
@@:
|
||||
add edi, 3
|
||||
dec ecx
|
||||
jz @f
|
||||
dec dword [esp]
|
||||
jnz .bpp24.dwordloop
|
||||
@@:
|
||||
pop eax
|
||||
test ecx, ecx
|
||||
jnz .bpp24.innloop
|
||||
sub esi, ebp
|
||||
pop ecx
|
||||
dec ebx
|
||||
jnz .bpp24.extloop
|
||||
pop eax ebx ebp
|
||||
ret 4
|
||||
.error.free2:
|
||||
pop ebx ebp
|
||||
.error.free:
|
||||
stdcall img._.delete, eax
|
||||
xor eax, eax
|
||||
ret 4
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below is private data you should never use directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
|
||||
;
|
||||
;;================================================================================================;;
|
||||
;;//// ico.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; References: ;;
|
||||
;; 1. "Icons in Win32" ;;
|
||||
;; by John Hornick, Microsoft Corporation ;;
|
||||
;; http://msdn2.microsoft.com/en-us/library/ms997538.aspx ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
include 'ico_cur.inc'
|
||||
|
||||
;;================================================================================================;;
|
||||
;;proc img.is.ico _data, _length ;////////////////////////////////////////////////////////////////;;
|
||||
img.is.ico:
|
||||
mov edx, 0x00010000 ; icon type = 1
|
||||
jmp @f
|
||||
img.is.cur:
|
||||
mov edx, 0x00020000 ; cursor type = 2
|
||||
@@:
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Determine if raw data could be decoded (is in ICO format) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = false / true ;;
|
||||
;;================================================================================================;;
|
||||
; test 1 (length of data): data must contain FileHeader
|
||||
mov ecx, [esp+8]
|
||||
sub ecx, sizeof.ico.FileHeader
|
||||
jb .nope
|
||||
; test 2: signature
|
||||
mov eax, [esp+4]
|
||||
cmp dword [eax], edx ; Reserved & Type
|
||||
jne .nope
|
||||
; test 3: count must be non-zero
|
||||
movzx eax, [eax + ico.FileHeader.Count]
|
||||
test eax, eax
|
||||
jz .nope
|
||||
; test 4 (length of data): data must containt Count dir entries
|
||||
shl eax, 4
|
||||
sub ecx, eax
|
||||
jae .yep
|
||||
|
||||
.nope:
|
||||
xor eax, eax
|
||||
ret 8
|
||||
|
||||
.yep:
|
||||
xor eax, eax
|
||||
inc eax
|
||||
ret 8
|
||||
;endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.ico_cur _data, _length, _options ;////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in ICO/CUR format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;> _options = options for decoding (e.g. background color) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
locals
|
||||
count dd ?
|
||||
img dd ?
|
||||
main_img dd ?
|
||||
endl
|
||||
|
||||
push ebx esi edi
|
||||
|
||||
; img.is.ico has been already called by img.decode
|
||||
; stdcall img.is.ico, [_data], [_length]
|
||||
; or eax, eax
|
||||
; jz .error
|
||||
|
||||
mov ebx, [_data]
|
||||
movzx eax, [ebx + ico.FileHeader.Count]
|
||||
mov [count], eax
|
||||
and [img], 0
|
||||
and [main_img], 0
|
||||
.loop:
|
||||
mov ecx, [ebx + sizeof.ico.FileHeader + ico.DirEntry.ByteSize]
|
||||
mov edx, [ebx + sizeof.ico.FileHeader + ico.DirEntry.ImageOffset]
|
||||
mov eax, [_length]
|
||||
sub eax, edx
|
||||
jb .skip
|
||||
cmp eax, ecx
|
||||
jb .skip
|
||||
cmp ecx, 12 ; length test, see img.is.bmp
|
||||
jb .skip
|
||||
add edx, [_data]
|
||||
push [_options]
|
||||
push ecx
|
||||
push edx
|
||||
call img.decode.ico._.decode_icon_data
|
||||
test eax, eax
|
||||
jz .skip
|
||||
push 0xFFFFFF ; set bgr to white if no given
|
||||
mov edx, [_options]
|
||||
test edx, edx
|
||||
jz @f
|
||||
cmp [edx + ImageDecodeOptions.UsedSize], ImageDecodeOptions.BackgroundColor + 4
|
||||
jb @f
|
||||
add esp, 4
|
||||
push [edx + ImageDecodeOptions.BackgroundColor]
|
||||
@@:
|
||||
call img.decode.ico._.decode_icon_mask
|
||||
test eax, eax
|
||||
jz .skip
|
||||
mov edx, [img]
|
||||
test edx, edx
|
||||
jz .first
|
||||
mov [edx + Image.Next], eax
|
||||
mov [eax + Image.Previous], edx
|
||||
jmp @f
|
||||
.first:
|
||||
mov [main_img], eax
|
||||
@@:
|
||||
mov [img], eax
|
||||
.skip:
|
||||
add ebx, sizeof.ico.DirEntry
|
||||
dec [count]
|
||||
jnz .loop
|
||||
|
||||
mov eax, [main_img]
|
||||
pop edi esi ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
img.encode.cur:
|
||||
proc img.encode.ico _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in ICO format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _img = pointer to image ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to encoded data ;;
|
||||
;< _p_length = encoded data length ;;
|
||||
;;================================================================================================;;
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below are private procs you should never call directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
img.decode.ico._.decode_icon_data:
|
||||
; create stack frame and jump to common BMP+ICO code
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
sub esp, 12
|
||||
mov byte [ebp - 3], 1 ; bIsIco
|
||||
jmp img.decode.bmp.common
|
||||
|
||||
img.decode.ico._.decode_icon_mask:
|
||||
mov edx, [eax + Image.Width]
|
||||
add edx, 31
|
||||
shr edx, 3
|
||||
and edx, not 3
|
||||
push edx
|
||||
imul edx, [eax + Image.Height]
|
||||
cmp ecx, edx
|
||||
pop edx
|
||||
jb .error.free
|
||||
mov edi, [eax + Image.Data]
|
||||
push ebp ebx eax
|
||||
xor ebp, ebp
|
||||
mov ebx, [eax + Image.Extended]
|
||||
cmp [ebx + bmp.Image.info.Height], 0
|
||||
js @f
|
||||
push edx
|
||||
imul edx, [eax + Image.Height]
|
||||
add esi, edx
|
||||
pop edx
|
||||
lea ebp, [edx+edx]
|
||||
sub esi, edx
|
||||
@@:
|
||||
mov ebx, [eax + Image.Height]
|
||||
mov ecx, [eax + Image.Width]
|
||||
; for now, BMP code produces only 8 and 32 bpp images
|
||||
cmp [eax + Image.Type], Image.bpp8i
|
||||
jz .bpp8
|
||||
.bpp32:
|
||||
mov edx, [esp+16] ; get background color
|
||||
.bpp32.extloop:
|
||||
push ecx
|
||||
.bpp32.innloop:
|
||||
lodsd
|
||||
bswap eax
|
||||
push 32
|
||||
.bpp32.dwordloop:
|
||||
add eax, eax
|
||||
jnc @f
|
||||
mov [edi], edx
|
||||
@@:
|
||||
add edi, 4
|
||||
dec ecx
|
||||
jz @f
|
||||
dec dword [esp]
|
||||
jnz .bpp32.dwordloop
|
||||
@@:
|
||||
pop eax
|
||||
test ecx, ecx
|
||||
jnz .bpp32.innloop
|
||||
sub esi, ebp
|
||||
pop ecx
|
||||
dec ebx
|
||||
jnz .bpp32.extloop
|
||||
pop eax ebx ebp
|
||||
ret 4
|
||||
.bpp8:
|
||||
push edi
|
||||
mov edi, [eax + Image.Palette]
|
||||
mov eax, [esp+20] ; get background color
|
||||
; if palette already has index for bgr color, use it
|
||||
push ecx
|
||||
mov ecx, 256
|
||||
repnz scasd
|
||||
jnz .bpp8.notfound
|
||||
not cl ; cl = index
|
||||
pop edx
|
||||
pop edi
|
||||
.bpp8.extloop:
|
||||
push edx
|
||||
.bpp8.innloop:
|
||||
lodsd
|
||||
bswap eax
|
||||
push 32
|
||||
.bpp8.dwordloop:
|
||||
add eax, eax
|
||||
jnc @f
|
||||
mov [edi], cl
|
||||
@@:
|
||||
inc edi
|
||||
dec edx
|
||||
jz @f
|
||||
dec dword [esp]
|
||||
jnz .bpp8.dwordloop
|
||||
@@:
|
||||
pop eax
|
||||
test edx, edx
|
||||
jnz .bpp8.innloop
|
||||
sub esi, ebp
|
||||
pop edx
|
||||
dec ebx
|
||||
jnz .bpp8.extloop
|
||||
pop eax ebx ebp
|
||||
ret 4
|
||||
.bpp8.notfound:
|
||||
; get maximum used color; if index < 255, then we can add one color to palette
|
||||
pop ecx
|
||||
pop edi
|
||||
pop eax
|
||||
mov edx, [eax + Image.Width]
|
||||
imul edx, ebx
|
||||
mov edi, [eax + Image.Data]
|
||||
xor ecx, ecx
|
||||
.bpp8.scanloop:
|
||||
cmp [edi], cl
|
||||
jb @f
|
||||
mov cl, [edi]
|
||||
@@:
|
||||
inc edi
|
||||
dec edx
|
||||
jnz .bpp8.scanloop
|
||||
inc cl
|
||||
jz .bpp8.nospace
|
||||
mov edx, [esp+8]
|
||||
mov edi, [eax + Image.Palette]
|
||||
mov [edi+ecx*4], edx ; set palette color
|
||||
mov edi, [eax + Image.Data]
|
||||
mov edx, [eax + Image.Width]
|
||||
push eax
|
||||
jmp .bpp8.extloop
|
||||
.bpp8.nospace:
|
||||
; convert to 24 bpp
|
||||
mov edx, [eax + Image.Width]
|
||||
imul edx, ebx
|
||||
lea edx, [edx*3]
|
||||
push eax
|
||||
invoke mem.alloc, edx
|
||||
mov edi, eax
|
||||
pop eax
|
||||
test edi, edi
|
||||
jz .error.free2
|
||||
push eax esi edi
|
||||
mov esi, eax
|
||||
call img._.do_rgb
|
||||
pop edi esi eax
|
||||
xchg edi, [eax + Image.Data]
|
||||
mov byte [eax + Image.Type], Image.bpp24
|
||||
push eax
|
||||
invoke mem.free, edi
|
||||
pop eax
|
||||
push eax
|
||||
mov ecx, [eax + Image.Width]
|
||||
mov edi, [eax + Image.Data]
|
||||
.bpp24:
|
||||
mov edx, [esp+16] ; get background color
|
||||
.bpp24.extloop:
|
||||
push ecx
|
||||
.bpp24.innloop:
|
||||
lodsd
|
||||
bswap eax
|
||||
push 32
|
||||
.bpp24.dwordloop:
|
||||
add eax, eax
|
||||
jnc @f
|
||||
mov [edi], dx
|
||||
ror edx, 16
|
||||
mov [edi+2], dl
|
||||
ror edx, 16
|
||||
@@:
|
||||
add edi, 3
|
||||
dec ecx
|
||||
jz @f
|
||||
dec dword [esp]
|
||||
jnz .bpp24.dwordloop
|
||||
@@:
|
||||
pop eax
|
||||
test ecx, ecx
|
||||
jnz .bpp24.innloop
|
||||
sub esi, ebp
|
||||
pop ecx
|
||||
dec ebx
|
||||
jnz .bpp24.extloop
|
||||
pop eax ebx ebp
|
||||
ret 4
|
||||
.error.free2:
|
||||
pop ebx ebp
|
||||
.error.free:
|
||||
stdcall img._.delete, eax
|
||||
xor eax, eax
|
||||
ret 4
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below is private data you should never use directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
|
||||
;
|
||||
|
@ -1,46 +1,46 @@
|
||||
;;================================================================================================;;
|
||||
;;//// ico.inc //// (c) diamond, 2009 ////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
struct ico.FileHeader
|
||||
Reserved dw ? ; must be 0
|
||||
Type dw ? ; must be 1
|
||||
Count dw ?
|
||||
ends
|
||||
|
||||
struct ico.DirEntry
|
||||
Width db ?
|
||||
Height db ?
|
||||
ColorCount db ?
|
||||
db ? ; reseved
|
||||
dw ? ; reserved
|
||||
dw ? ; reserved
|
||||
ByteSize dd ?
|
||||
ImageOffset dd ?
|
||||
ends
|
||||
|
||||
struct cur.DirEntry
|
||||
Width db ?
|
||||
Height db ?
|
||||
ColorCount db ?
|
||||
db ? ; reserved
|
||||
XHotSpot dw ?
|
||||
YHotSpot dw ?
|
||||
ByteSize dd ?
|
||||
ImageOffset dd ?
|
||||
ends
|
||||
;;================================================================================================;;
|
||||
;;//// ico.inc //// (c) diamond, 2009 ////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
struct ico.FileHeader
|
||||
Reserved dw ? ; must be 0
|
||||
Type dw ? ; must be 1
|
||||
Count dw ?
|
||||
ends
|
||||
|
||||
struct ico.DirEntry
|
||||
Width db ?
|
||||
Height db ?
|
||||
ColorCount db ?
|
||||
db ? ; reseved
|
||||
dw ? ; reserved
|
||||
dw ? ; reserved
|
||||
ByteSize dd ?
|
||||
ImageOffset dd ?
|
||||
ends
|
||||
|
||||
struct cur.DirEntry
|
||||
Width db ?
|
||||
Height db ?
|
||||
ColorCount db ?
|
||||
db ? ; reserved
|
||||
XHotSpot dw ?
|
||||
YHotSpot dw ?
|
||||
ByteSize dd ?
|
||||
ImageOffset dd ?
|
||||
ends
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,96 +1,96 @@
|
||||
;;================================================================================================;;
|
||||
;;//// jpeg.inc //// (c) diamond, 2008-2009 //////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
struct jpeg.work ; working area for JPEG handling
|
||||
image dd ?
|
||||
; progressive JPEG?
|
||||
progressive db ?
|
||||
; one component in the scan?
|
||||
not_interleaved db ?
|
||||
; Adobe YCCK file?
|
||||
adobe_ycck db ?
|
||||
rb 1
|
||||
; parameters for progressive scan
|
||||
ScanStart db ?
|
||||
ScanEnd db ?
|
||||
ApproxPosLow db ?
|
||||
ApproxPosHigh db ?
|
||||
; restart interval
|
||||
restart_interval dd ?
|
||||
decoded_MCUs dd ?
|
||||
|
||||
_esp dd ?
|
||||
|
||||
; components information, up to 4 components
|
||||
; db ComponentIdentifier, db V, db H, db VFactor, db HFactor, db QuantizationTable
|
||||
components rb 4*6
|
||||
max_v db ?
|
||||
max_h db ?
|
||||
cur_rst_marker db ?
|
||||
db ?
|
||||
huffman_bits dd ?
|
||||
block_width dd ?
|
||||
block_height dd ?
|
||||
block_delta_x dd ?
|
||||
block_delta_y dd ?
|
||||
cur_block_dx dd ?
|
||||
cur_block_dy dd ?
|
||||
x_num_blocks dd ?
|
||||
y_num_blocks dd ?
|
||||
delta_x dd ?
|
||||
delta_y dd ?
|
||||
pixel_size dd ?
|
||||
line_size dd ?
|
||||
cur_x dd ?
|
||||
cur_y dd ?
|
||||
max_x dd ?
|
||||
max_y dd ?
|
||||
cur_out_ptr dd ?
|
||||
dct_buffer dd ?
|
||||
dct_buffer_size dd ?
|
||||
;ns dd ?
|
||||
; +0: db V, db H, db VFactor, db HFactor, dd HIncrement, dd VIncrement,
|
||||
; +12: dd QuantizationTable, dd DCTable, dd ACTable,
|
||||
; +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),
|
||||
; +48: dw DCPrediction, db ?, db (0 for Y, 80h for Cb,Cr), dd ComponentOffset
|
||||
cur_components rb 4*56
|
||||
cur_components_end dd ?
|
||||
; Fourier coefficients
|
||||
dct_coeff rw 64
|
||||
; Temporary space for IDCT
|
||||
idct_tmp_area rd 64
|
||||
; decoded block 8*8
|
||||
decoded_data rb 8*8
|
||||
; up to 4 quantization tables
|
||||
quant_tables rd 4*64
|
||||
quant_tables_defined rb 4
|
||||
|
||||
; Huffman tables
|
||||
dc_huffman_defined rb 4
|
||||
ac_huffman_defined rb 4
|
||||
; up to 4 DC Huffman tables
|
||||
;dc_huffman rd 4*256*2
|
||||
; up to 4 AC Huffman tables
|
||||
;ac_huffman rd 4*256*2
|
||||
max_hufftable_size = (256 + (9+128)*16)*2
|
||||
dc_huffman rb 4*max_hufftable_size
|
||||
ac_huffman rb 4*max_hufftable_size
|
||||
|
||||
ends
|
||||
;;================================================================================================;;
|
||||
;;//// jpeg.inc //// (c) diamond, 2008-2009 //////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
struct jpeg.work ; working area for JPEG handling
|
||||
image dd ?
|
||||
; progressive JPEG?
|
||||
progressive db ?
|
||||
; one component in the scan?
|
||||
not_interleaved db ?
|
||||
; Adobe YCCK file?
|
||||
adobe_ycck db ?
|
||||
rb 1
|
||||
; parameters for progressive scan
|
||||
ScanStart db ?
|
||||
ScanEnd db ?
|
||||
ApproxPosLow db ?
|
||||
ApproxPosHigh db ?
|
||||
; restart interval
|
||||
restart_interval dd ?
|
||||
decoded_MCUs dd ?
|
||||
|
||||
_esp dd ?
|
||||
|
||||
; components information, up to 4 components
|
||||
; db ComponentIdentifier, db V, db H, db VFactor, db HFactor, db QuantizationTable
|
||||
components rb 4*6
|
||||
max_v db ?
|
||||
max_h db ?
|
||||
cur_rst_marker db ?
|
||||
db ?
|
||||
huffman_bits dd ?
|
||||
block_width dd ?
|
||||
block_height dd ?
|
||||
block_delta_x dd ?
|
||||
block_delta_y dd ?
|
||||
cur_block_dx dd ?
|
||||
cur_block_dy dd ?
|
||||
x_num_blocks dd ?
|
||||
y_num_blocks dd ?
|
||||
delta_x dd ?
|
||||
delta_y dd ?
|
||||
pixel_size dd ?
|
||||
line_size dd ?
|
||||
cur_x dd ?
|
||||
cur_y dd ?
|
||||
max_x dd ?
|
||||
max_y dd ?
|
||||
cur_out_ptr dd ?
|
||||
dct_buffer dd ?
|
||||
dct_buffer_size dd ?
|
||||
;ns dd ?
|
||||
; +0: db V, db H, db VFactor, db HFactor, dd HIncrement, dd VIncrement,
|
||||
; +12: dd QuantizationTable, dd DCTable, dd ACTable,
|
||||
; +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),
|
||||
; +48: dw DCPrediction, db ?, db (0 for Y, 80h for Cb,Cr), dd ComponentOffset
|
||||
cur_components rb 4*56
|
||||
cur_components_end dd ?
|
||||
; Fourier coefficients
|
||||
dct_coeff rw 64
|
||||
; Temporary space for IDCT
|
||||
idct_tmp_area rd 64
|
||||
; decoded block 8*8
|
||||
decoded_data rb 8*8
|
||||
; up to 4 quantization tables
|
||||
quant_tables rd 4*64
|
||||
quant_tables_defined rb 4
|
||||
|
||||
; Huffman tables
|
||||
dc_huffman_defined rb 4
|
||||
ac_huffman_defined rb 4
|
||||
; up to 4 DC Huffman tables
|
||||
;dc_huffman rd 4*256*2
|
||||
; up to 4 AC Huffman tables
|
||||
;ac_huffman rd 4*256*2
|
||||
max_hufftable_size = (256 + (9+128)*16)*2
|
||||
dc_huffman rb 4*max_hufftable_size
|
||||
ac_huffman rb 4*max_hufftable_size
|
||||
|
||||
ends
|
||||
|
@ -22,14 +22,14 @@ format MS COFF
|
||||
|
||||
public @EXPORT as 'EXPORTS'
|
||||
|
||||
include '../../../../struct.inc'
|
||||
include '../../../../proc32.inc'
|
||||
include '../../../../macros.inc'
|
||||
include '../../../../config.inc'
|
||||
include '../../../../debug-fdo.inc'
|
||||
include 'struct.inc'
|
||||
include 'proc32.inc'
|
||||
include 'macros.inc'
|
||||
include 'config.inc'
|
||||
include 'debug-fdo.inc'
|
||||
__DEBUG__ = 0
|
||||
__DEBUG_LEVEL__ = 1
|
||||
include '../../../../develop/libraries/libs-dev/libio/libio.inc'
|
||||
include 'libio.inc'
|
||||
purge section,mov,add,sub
|
||||
|
||||
include 'libimg.inc'
|
||||
@ -53,6 +53,11 @@ include 'xbm/xbm.asm'
|
||||
include 'scale.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 ;///////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
@ -2743,6 +2748,7 @@ img._.get_scanline_len: ;///////////////////////////////////////////////////////
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
section '.data' data readable writable align 16
|
||||
;include_debug_strings
|
||||
|
||||
align 4
|
||||
@ -2807,6 +2813,7 @@ export \
|
||||
img.scale , 'img_scale' , \
|
||||
img.get_scaled_size, 'img_get_scaled_size', \
|
||||
img.convert , 'img_convert' , \
|
||||
img.blend , 'img_blend' , \
|
||||
img.formats_table , 'img_formats_table'
|
||||
|
||||
; import from deflate unpacker
|
||||
@ -2841,7 +2848,6 @@ gif_default_palette:
|
||||
db 0, 0, 0
|
||||
db 0xFF, 0xFF, 0xFF
|
||||
|
||||
section '.data' data readable writable align 16
|
||||
; uninitialized data - global constant tables
|
||||
mem.alloc dd ?
|
||||
mem.free dd ?
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,253 +1,253 @@
|
||||
|
||||
; pnginfo.inc - header file for PNG reference library
|
||||
|
||||
; Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
; Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
|
||||
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
||||
; This code is released under the libpng license.
|
||||
; For conditions of distribution and use, see the disclaimer
|
||||
; and license in png.inc
|
||||
|
||||
; 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.
|
||||
; 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
|
||||
; you want to put into the PNG file, using png_set_*() functions, then
|
||||
; call png_write_info().
|
||||
|
||||
; The names chosen should be very close to the PNG specification, so
|
||||
; 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
|
||||
; 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,
|
||||
; however, there are now functions that abstract the contents of
|
||||
; png_info_struct from the application, so this makes it easier 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
|
||||
; functionality. In libpng-1.5.0 this was moved into a separate private
|
||||
; file that is not visible to applications.
|
||||
|
||||
; The following members may have allocated storage attached that should be
|
||||
; cleaned up before the structure is discarded: palette, trans, text,
|
||||
; pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
|
||||
; splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
|
||||
; are automatically freed when the info structure is deallocated, if they were
|
||||
; allocated internally by libpng. This behavior can be changed by means
|
||||
; of the png_data_freer() function.
|
||||
|
||||
; More allocation details: all the chunk-reading functions that
|
||||
; change these members go through the corresponding png_set_*
|
||||
; functions. A function to clear these members is available: see
|
||||
; 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
|
||||
; 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
|
||||
; itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
|
||||
; functions do not make their own copies.
|
||||
|
||||
|
||||
struct png_info_def
|
||||
; The following are necessary for every PNG file
|
||||
width dd ? ;uint_32 ;width 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)
|
||||
rowbytes dd ? ;png_size_t ;bytes needed to hold an untransformed row
|
||||
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_trans dw ? ;uint_16 ;number of transparent palette color (tRNS)
|
||||
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)
|
||||
; The following three should have been named *_method not *_type
|
||||
compression_type db ? ;byte ;must be PNG_COMPRESSION_TYPE_BASE (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
|
||||
|
||||
; The following are set by png_set_IHDR, called from the application on
|
||||
; write, but the are never actually used by the write code.
|
||||
|
||||
channels db ? ;byte ;number of data channels per pixel (1, 2, 3, 4)
|
||||
pixel_depth db ? ;byte ;number of bits per pixel
|
||||
spare_byte db ? ;byte ;to align the data, and for future use
|
||||
|
||||
if PNG_READ_SUPPORTED eq 1
|
||||
; This is never set during write
|
||||
signature db 8 ;byte[8] ;magic bytes read by libpng from start of file
|
||||
end if
|
||||
|
||||
; 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
|
||||
; are writing, set the valid field to those chunks you want written,
|
||||
; and initialize the appropriate fields below.
|
||||
|
||||
|
||||
if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
|
||||
; png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
||||
; 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. If this is not done it becomes possible to read
|
||||
; inconsistent PNG files and assign a probably incorrect interpretation to
|
||||
; the information. (In other words, by carefully choosing which chunks to
|
||||
; recognize the system configuration can select an interpretation for PNG
|
||||
; files containing ambiguous data and this will result in inconsistent
|
||||
; behavior between different libpng builds!)
|
||||
|
||||
colorspace png_colorspace
|
||||
end if
|
||||
|
||||
if PNG_iCCP_SUPPORTED eq 1
|
||||
; iCCP chunk data.
|
||||
iccp_name dd ? ;charp ;profile name
|
||||
iccp_profile dd ? ;bytep ;International Color Consortium profile data
|
||||
iccp_proflen dd ? ;uint_32 ;ICC profile data length
|
||||
end if
|
||||
|
||||
if PNG_TEXT_SUPPORTED eq 1
|
||||
; The tEXt, and zTXt chunks contain human-readable textual data in
|
||||
; uncompressed, compressed, and optionally compressed forms, respectively.
|
||||
; The data in "text" is an array of pointers to uncompressed,
|
||||
; null-terminated C strings. Each chunk has a keyword that describes the
|
||||
; 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
|
||||
; be in an image.
|
||||
|
||||
num_text dd ? ;int ;number of comments read or comments to write
|
||||
max_text dd ? ;int ;current size of text array
|
||||
text dd ? ;png_textp ;array of comments read or comments to write
|
||||
end if ;TEXT
|
||||
|
||||
if PNG_tIME_SUPPORTED eq 1
|
||||
; The tIME chunk holds the last time the displayed image data was
|
||||
; modified. See the png_time struct for the contents of this struct.
|
||||
|
||||
mod_time png_time
|
||||
end if
|
||||
|
||||
if PNG_sBIT_SUPPORTED eq 1
|
||||
; 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
|
||||
; only specified for the channels in the pixel data. The contents of
|
||||
; the low-order bits is not specified. Data is valid if
|
||||
; (valid & PNG_INFO_sBIT) is non-zero.
|
||||
|
||||
sig_bit png_color_8 ; significant bits in color channels
|
||||
end if
|
||||
|
||||
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
|
||||
; other image types that don't need a full alpha channel. There are
|
||||
; "num_trans" transparency values for a paletted image, stored in the
|
||||
; same order as the palette colors, starting from index 0. Values
|
||||
; for the data are in the range [0, 255], ranging from fully transparent
|
||||
; to fully opaque, respectively. For non-paletted images, there is a
|
||||
; single color specified that should be treated as fully transparent.
|
||||
; Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
|
||||
|
||||
trans_alpha dd ? ;bytep ; alpha values for paletted image
|
||||
trans_color png_color_16 ;transparent color for non-palette image
|
||||
end if
|
||||
|
||||
if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
|
||||
; The bKGD chunk gives the suggested image background color if the
|
||||
; display program does not have its own background color and the image
|
||||
; is needs to composited onto a background before display. The colors
|
||||
; 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.
|
||||
|
||||
background png_color_16
|
||||
end if
|
||||
|
||||
if PNG_oFFs_SUPPORTED eq 1
|
||||
; 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
|
||||
; application-specific co-ordinate space. See the PNG_OFFSET_ defines
|
||||
; below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
|
||||
|
||||
x_offset dd ? ;int_32 ;x offset on page
|
||||
y_offset dd ? ;int_32 ;y offset on page
|
||||
offset_unit_type db ? ;byte ;offset units type
|
||||
end if
|
||||
|
||||
if PNG_pHYs_SUPPORTED eq 1
|
||||
; The pHYs chunk gives the physical pixel density of the image for
|
||||
; display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
|
||||
; defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
|
||||
|
||||
x_pixels_per_unit dd ? ;uint_32 ;horizontal pixel density
|
||||
y_pixels_per_unit dd ? ;uint_32 ;vertical pixel density
|
||||
phys_unit_type db ? ;byte ;resolution type (see PNG_RESOLUTION_ below)
|
||||
end if
|
||||
|
||||
if PNG_hIST_SUPPORTED eq 1
|
||||
; The hIST chunk contains the relative frequency or importance of the
|
||||
; various palette entries, so that a viewer can intelligently select a
|
||||
; 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)
|
||||
; is non-zero.
|
||||
|
||||
hist dd ? ;uint_16p
|
||||
end if
|
||||
|
||||
if PNG_pCAL_SUPPORTED eq 1
|
||||
; The pCAL chunk describes a transformation between the stored pixel
|
||||
; values and original physical data values used to create the image.
|
||||
; 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
|
||||
; (possibly non-linear) transformation function given by "pcal_type"
|
||||
; and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
|
||||
; defines below, and the PNG-Group's PNG extensions document for a
|
||||
; complete description of the transformations and how they should be
|
||||
; implemented, and for a description of the ASCII parameter strings.
|
||||
; Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
|
||||
|
||||
pcal_purpose dd ? ;charp ;pCAL chunk description string
|
||||
pcal_X0 dd ? ;int_32 ;minimum value
|
||||
pcal_X1 dd ? ;int_32 ;maximum value
|
||||
pcal_units dd ? ;charp ;Latin-1 string giving physical units
|
||||
pcal_params dd ? ;charpp ;ASCII strings containing parameter values
|
||||
pcal_type db ? ;byte ;equation type (see PNG_EQUATION_ below)
|
||||
pcal_nparams db ? ;byte ;number of parameters given in pcal_params
|
||||
end if
|
||||
|
||||
; New members added in libpng-1.0.6
|
||||
free_me dd ? ;uint_32 ;flags items libpng is responsible for freeing
|
||||
|
||||
if PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED eq 1
|
||||
; Storage for unknown chunks that the library doesn't recognize.
|
||||
unknown_chunks dd ? ;png_unknown_chunkp
|
||||
|
||||
; The type of this field is limited by the type of
|
||||
; png_struct::user_chunk_cache_max, else overflow can occur.
|
||||
|
||||
unknown_chunks_num dd ? ;int
|
||||
end if
|
||||
|
||||
if PNG_sPLT_SUPPORTED eq 1
|
||||
; Data on sPLT chunks (there may be more than one).
|
||||
splt_palettes dd ? ;png_sPLT_tp
|
||||
splt_palettes_num dd ? ;int ;Match type returned by png_get API
|
||||
end if
|
||||
|
||||
if PNG_sCAL_SUPPORTED eq 1
|
||||
; The sCAL chunk describes the actual physical dimensions of the
|
||||
; subject matter of the graphic. The chunk contains a unit specification
|
||||
; a byte value, and two ASCII strings representing floating-point
|
||||
; values. The values are width and height corresponsing to one pixel
|
||||
; in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
|
||||
; non-zero.
|
||||
|
||||
scal_unit db ? ;byte ;unit of physical scale
|
||||
scal_s_width dd ? ;charp ;string containing height
|
||||
scal_s_height dd ? ;charp ;string containing width
|
||||
end if
|
||||
|
||||
if PNG_INFO_IMAGE_SUPPORTED eq 1
|
||||
; Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
|
||||
; non-zero
|
||||
; Data valid if (valid & PNG_INFO_IDAT) non-zero
|
||||
row_pointers dd ? ;bytepp ;the image bits
|
||||
end if
|
||||
|
||||
ends
|
||||
|
||||
; pnginfo.inc - header file for PNG reference library
|
||||
|
||||
; Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
; Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
|
||||
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
||||
; This code is released under the libpng license.
|
||||
; For conditions of distribution and use, see the disclaimer
|
||||
; and license in png.inc
|
||||
|
||||
; 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.
|
||||
; 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
|
||||
; you want to put into the PNG file, using png_set_*() functions, then
|
||||
; call png_write_info().
|
||||
|
||||
; The names chosen should be very close to the PNG specification, so
|
||||
; 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
|
||||
; 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,
|
||||
; however, there are now functions that abstract the contents of
|
||||
; png_info_struct from the application, so this makes it easier 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
|
||||
; functionality. In libpng-1.5.0 this was moved into a separate private
|
||||
; file that is not visible to applications.
|
||||
|
||||
; The following members may have allocated storage attached that should be
|
||||
; cleaned up before the structure is discarded: palette, trans, text,
|
||||
; pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
|
||||
; splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
|
||||
; are automatically freed when the info structure is deallocated, if they were
|
||||
; allocated internally by libpng. This behavior can be changed by means
|
||||
; of the png_data_freer() function.
|
||||
|
||||
; More allocation details: all the chunk-reading functions that
|
||||
; change these members go through the corresponding png_set_*
|
||||
; functions. A function to clear these members is available: see
|
||||
; 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
|
||||
; 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
|
||||
; itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
|
||||
; functions do not make their own copies.
|
||||
|
||||
|
||||
struct png_info_def
|
||||
; The following are necessary for every PNG file
|
||||
width dd ? ;uint_32 ;width 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)
|
||||
rowbytes dd ? ;png_size_t ;bytes needed to hold an untransformed row
|
||||
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_trans dw ? ;uint_16 ;number of transparent palette color (tRNS)
|
||||
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)
|
||||
; The following three should have been named *_method not *_type
|
||||
compression_type db ? ;byte ;must be PNG_COMPRESSION_TYPE_BASE (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
|
||||
|
||||
; The following are set by png_set_IHDR, called from the application on
|
||||
; write, but the are never actually used by the write code.
|
||||
|
||||
channels db ? ;byte ;number of data channels per pixel (1, 2, 3, 4)
|
||||
pixel_depth db ? ;byte ;number of bits per pixel
|
||||
spare_byte db ? ;byte ;to align the data, and for future use
|
||||
|
||||
if PNG_READ_SUPPORTED eq 1
|
||||
; This is never set during write
|
||||
signature db 8 ;byte[8] ;magic bytes read by libpng from start of file
|
||||
end if
|
||||
|
||||
; 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
|
||||
; are writing, set the valid field to those chunks you want written,
|
||||
; and initialize the appropriate fields below.
|
||||
|
||||
|
||||
if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
|
||||
; png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
||||
; 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. If this is not done it becomes possible to read
|
||||
; inconsistent PNG files and assign a probably incorrect interpretation to
|
||||
; the information. (In other words, by carefully choosing which chunks to
|
||||
; recognize the system configuration can select an interpretation for PNG
|
||||
; files containing ambiguous data and this will result in inconsistent
|
||||
; behavior between different libpng builds!)
|
||||
|
||||
colorspace png_colorspace
|
||||
end if
|
||||
|
||||
if PNG_iCCP_SUPPORTED eq 1
|
||||
; iCCP chunk data.
|
||||
iccp_name dd ? ;charp ;profile name
|
||||
iccp_profile dd ? ;bytep ;International Color Consortium profile data
|
||||
iccp_proflen dd ? ;uint_32 ;ICC profile data length
|
||||
end if
|
||||
|
||||
if PNG_TEXT_SUPPORTED eq 1
|
||||
; The tEXt, and zTXt chunks contain human-readable textual data in
|
||||
; uncompressed, compressed, and optionally compressed forms, respectively.
|
||||
; The data in "text" is an array of pointers to uncompressed,
|
||||
; null-terminated C strings. Each chunk has a keyword that describes the
|
||||
; 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
|
||||
; be in an image.
|
||||
|
||||
num_text dd ? ;int ;number of comments read or comments to write
|
||||
max_text dd ? ;int ;current size of text array
|
||||
text dd ? ;png_textp ;array of comments read or comments to write
|
||||
end if ;TEXT
|
||||
|
||||
if PNG_tIME_SUPPORTED eq 1
|
||||
; The tIME chunk holds the last time the displayed image data was
|
||||
; modified. See the png_time struct for the contents of this struct.
|
||||
|
||||
mod_time png_time
|
||||
end if
|
||||
|
||||
if PNG_sBIT_SUPPORTED eq 1
|
||||
; 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
|
||||
; only specified for the channels in the pixel data. The contents of
|
||||
; the low-order bits is not specified. Data is valid if
|
||||
; (valid & PNG_INFO_sBIT) is non-zero.
|
||||
|
||||
sig_bit png_color_8 ; significant bits in color channels
|
||||
end if
|
||||
|
||||
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
|
||||
; other image types that don't need a full alpha channel. There are
|
||||
; "num_trans" transparency values for a paletted image, stored in the
|
||||
; same order as the palette colors, starting from index 0. Values
|
||||
; for the data are in the range [0, 255], ranging from fully transparent
|
||||
; to fully opaque, respectively. For non-paletted images, there is a
|
||||
; single color specified that should be treated as fully transparent.
|
||||
; Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
|
||||
|
||||
trans_alpha dd ? ;bytep ; alpha values for paletted image
|
||||
trans_color png_color_16 ;transparent color for non-palette image
|
||||
end if
|
||||
|
||||
if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1)
|
||||
; The bKGD chunk gives the suggested image background color if the
|
||||
; display program does not have its own background color and the image
|
||||
; is needs to composited onto a background before display. The colors
|
||||
; 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.
|
||||
|
||||
background png_color_16
|
||||
end if
|
||||
|
||||
if PNG_oFFs_SUPPORTED eq 1
|
||||
; 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
|
||||
; application-specific co-ordinate space. See the PNG_OFFSET_ defines
|
||||
; below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
|
||||
|
||||
x_offset dd ? ;int_32 ;x offset on page
|
||||
y_offset dd ? ;int_32 ;y offset on page
|
||||
offset_unit_type db ? ;byte ;offset units type
|
||||
end if
|
||||
|
||||
if PNG_pHYs_SUPPORTED eq 1
|
||||
; The pHYs chunk gives the physical pixel density of the image for
|
||||
; display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
|
||||
; defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
|
||||
|
||||
x_pixels_per_unit dd ? ;uint_32 ;horizontal pixel density
|
||||
y_pixels_per_unit dd ? ;uint_32 ;vertical pixel density
|
||||
phys_unit_type db ? ;byte ;resolution type (see PNG_RESOLUTION_ below)
|
||||
end if
|
||||
|
||||
if PNG_hIST_SUPPORTED eq 1
|
||||
; The hIST chunk contains the relative frequency or importance of the
|
||||
; various palette entries, so that a viewer can intelligently select a
|
||||
; 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)
|
||||
; is non-zero.
|
||||
|
||||
hist dd ? ;uint_16p
|
||||
end if
|
||||
|
||||
if PNG_pCAL_SUPPORTED eq 1
|
||||
; The pCAL chunk describes a transformation between the stored pixel
|
||||
; values and original physical data values used to create the image.
|
||||
; 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
|
||||
; (possibly non-linear) transformation function given by "pcal_type"
|
||||
; and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
|
||||
; defines below, and the PNG-Group's PNG extensions document for a
|
||||
; complete description of the transformations and how they should be
|
||||
; implemented, and for a description of the ASCII parameter strings.
|
||||
; Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
|
||||
|
||||
pcal_purpose dd ? ;charp ;pCAL chunk description string
|
||||
pcal_X0 dd ? ;int_32 ;minimum value
|
||||
pcal_X1 dd ? ;int_32 ;maximum value
|
||||
pcal_units dd ? ;charp ;Latin-1 string giving physical units
|
||||
pcal_params dd ? ;charpp ;ASCII strings containing parameter values
|
||||
pcal_type db ? ;byte ;equation type (see PNG_EQUATION_ below)
|
||||
pcal_nparams db ? ;byte ;number of parameters given in pcal_params
|
||||
end if
|
||||
|
||||
; New members added in libpng-1.0.6
|
||||
free_me dd ? ;uint_32 ;flags items libpng is responsible for freeing
|
||||
|
||||
if PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED eq 1
|
||||
; Storage for unknown chunks that the library doesn't recognize.
|
||||
unknown_chunks dd ? ;png_unknown_chunkp
|
||||
|
||||
; The type of this field is limited by the type of
|
||||
; png_struct::user_chunk_cache_max, else overflow can occur.
|
||||
|
||||
unknown_chunks_num dd ? ;int
|
||||
end if
|
||||
|
||||
if PNG_sPLT_SUPPORTED eq 1
|
||||
; Data on sPLT chunks (there may be more than one).
|
||||
splt_palettes dd ? ;png_sPLT_tp
|
||||
splt_palettes_num dd ? ;int ;Match type returned by png_get API
|
||||
end if
|
||||
|
||||
if PNG_sCAL_SUPPORTED eq 1
|
||||
; The sCAL chunk describes the actual physical dimensions of the
|
||||
; subject matter of the graphic. The chunk contains a unit specification
|
||||
; a byte value, and two ASCII strings representing floating-point
|
||||
; values. The values are width and height corresponsing to one pixel
|
||||
; in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
|
||||
; non-zero.
|
||||
|
||||
scal_unit db ? ;byte ;unit of physical scale
|
||||
scal_s_width dd ? ;charp ;string containing height
|
||||
scal_s_height dd ? ;charp ;string containing width
|
||||
end if
|
||||
|
||||
if PNG_INFO_IMAGE_SUPPORTED eq 1
|
||||
; Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS)
|
||||
; non-zero
|
||||
; Data valid if (valid & PNG_INFO_IDAT) non-zero
|
||||
row_pointers dd ? ;bytepp ;the image bits
|
||||
end if
|
||||
|
||||
ends
|
||||
|
@ -1,209 +1,209 @@
|
||||
; libpng 1.6.25 STANDARD API DEFINITION
|
||||
|
||||
; pnglibconf.inc - library build configuration
|
||||
|
||||
; Libpng version 1.6.25 - September 1, 2016
|
||||
|
||||
; Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
|
||||
; This code is released under the libpng license.
|
||||
; For conditions of distribution and use, see the disclaimer
|
||||
; and license in png.inc
|
||||
|
||||
; pnglibconf.inc
|
||||
; Machine generated file: DO NOT EDIT
|
||||
; Derived from: scripts/pnglibconf.dfa
|
||||
|
||||
; options
|
||||
PNG_16BIT_SUPPORTED equ 1
|
||||
PNG_ALIGNED_MEMORY_SUPPORTED equ 1
|
||||
;/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
||||
;/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||
PNG_BENIGN_ERRORS_SUPPORTED equ 1
|
||||
PNG_BENIGN_READ_ERRORS_SUPPORTED equ 1
|
||||
;/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||
PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED equ 1
|
||||
PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 1
|
||||
PNG_COLORSPACE_SUPPORTED equ 1
|
||||
PNG_CONSOLE_IO_SUPPORTED equ 1
|
||||
PNG_CONVERT_tIME_SUPPORTED equ 1
|
||||
PNG_EASY_ACCESS_SUPPORTED equ 1
|
||||
;/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||
PNG_ERROR_TEXT_SUPPORTED equ 1
|
||||
PNG_FIXED_POINT_SUPPORTED equ 1
|
||||
PNG_FLOATING_ARITHMETIC_SUPPORTED equ 1
|
||||
PNG_FLOATING_POINT_SUPPORTED equ 1
|
||||
PNG_FORMAT_AFIRST_SUPPORTED equ 1
|
||||
PNG_FORMAT_BGR_SUPPORTED equ 1
|
||||
PNG_GAMMA_SUPPORTED equ 1
|
||||
PNG_GET_PALETTE_MAX_SUPPORTED equ 1
|
||||
PNG_HANDLE_AS_UNKNOWN_SUPPORTED equ 1
|
||||
PNG_INCH_CONVERSIONS_SUPPORTED equ 1
|
||||
PNG_INFO_IMAGE_SUPPORTED equ 1
|
||||
PNG_IO_STATE_SUPPORTED equ 1
|
||||
PNG_MNG_FEATURES_SUPPORTED equ 0
|
||||
PNG_POINTER_INDEXING_SUPPORTED equ 1
|
||||
PNG_PROGRESSIVE_READ_SUPPORTED equ 0
|
||||
PNG_READ_16BIT_SUPPORTED equ 0
|
||||
PNG_READ_ALPHA_MODE_SUPPORTED equ 0
|
||||
PNG_READ_ANCILLARY_CHUNKS_SUPPORTED equ 0
|
||||
PNG_READ_BACKGROUND_SUPPORTED equ 0
|
||||
PNG_READ_BGR_SUPPORTED equ 0
|
||||
PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 0
|
||||
PNG_READ_COMPOSITE_NODIV_SUPPORTED equ 0
|
||||
PNG_READ_COMPRESSED_TEXT_SUPPORTED equ 0
|
||||
PNG_READ_EXPAND_16_SUPPORTED equ 0
|
||||
PNG_READ_EXPAND_SUPPORTED equ 0
|
||||
PNG_READ_FILLER_SUPPORTED equ 0
|
||||
PNG_READ_GAMMA_SUPPORTED equ 0
|
||||
PNG_READ_GET_PALETTE_MAX_SUPPORTED equ 0
|
||||
PNG_READ_GRAY_TO_RGB_SUPPORTED equ 0
|
||||
PNG_READ_INTERLACING_SUPPORTED equ 0
|
||||
PNG_READ_INT_FUNCTIONS_SUPPORTED equ 0
|
||||
PNG_READ_INVERT_ALPHA_SUPPORTED equ 0
|
||||
PNG_READ_INVERT_SUPPORTED equ 0
|
||||
PNG_READ_OPT_PLTE_SUPPORTED equ 0
|
||||
PNG_READ_PACKSWAP_SUPPORTED equ 0
|
||||
PNG_READ_PACK_SUPPORTED equ 0
|
||||
PNG_READ_QUANTIZE_SUPPORTED equ 0
|
||||
PNG_READ_RGB_TO_GRAY_SUPPORTED equ 0
|
||||
PNG_READ_SCALE_16_TO_8_SUPPORTED equ 0
|
||||
PNG_READ_SHIFT_SUPPORTED equ 0
|
||||
PNG_READ_STRIP_16_TO_8_SUPPORTED equ 0
|
||||
PNG_READ_STRIP_ALPHA_SUPPORTED equ 0
|
||||
PNG_READ_SUPPORTED equ 0
|
||||
PNG_READ_SWAP_ALPHA_SUPPORTED equ 0
|
||||
PNG_READ_SWAP_SUPPORTED equ 0
|
||||
PNG_READ_TEXT_SUPPORTED equ 0
|
||||
PNG_READ_TRANSFORMS_SUPPORTED equ 0
|
||||
PNG_READ_UNKNOWN_CHUNKS_SUPPORTED equ 0
|
||||
PNG_READ_USER_CHUNKS_SUPPORTED equ 0
|
||||
PNG_READ_USER_TRANSFORM_SUPPORTED equ 0
|
||||
PNG_READ_bKGD_SUPPORTED equ 0
|
||||
PNG_READ_cHRM_SUPPORTED equ 0
|
||||
PNG_READ_gAMA_SUPPORTED equ 0
|
||||
PNG_READ_hIST_SUPPORTED equ 0
|
||||
PNG_READ_iCCP_SUPPORTED equ 0
|
||||
PNG_READ_iTXt_SUPPORTED equ 0
|
||||
PNG_READ_oFFs_SUPPORTED equ 0
|
||||
PNG_READ_pCAL_SUPPORTED equ 0
|
||||
PNG_READ_pHYs_SUPPORTED equ 0
|
||||
PNG_READ_sBIT_SUPPORTED equ 0
|
||||
PNG_READ_sCAL_SUPPORTED equ 0
|
||||
PNG_READ_sPLT_SUPPORTED equ 0
|
||||
PNG_READ_sRGB_SUPPORTED equ 0
|
||||
PNG_READ_tEXt_SUPPORTED equ 0
|
||||
PNG_READ_tIME_SUPPORTED equ 0
|
||||
PNG_READ_tRNS_SUPPORTED equ 0
|
||||
PNG_READ_zTXt_SUPPORTED equ 0
|
||||
PNG_SAVE_INT_32_SUPPORTED equ 1
|
||||
PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED equ 1
|
||||
PNG_SEQUENTIAL_READ_SUPPORTED equ 1
|
||||
PNG_SETJMP_SUPPORTED equ 0 ;1 ;setjmp.h — заголовочный файл стандартной библиотеки языка Си
|
||||
PNG_SET_OPTION_SUPPORTED equ 1
|
||||
PNG_SET_UNKNOWN_CHUNKS_SUPPORTED equ 1
|
||||
PNG_SET_USER_LIMITS_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_READ_BGR_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_READ_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED equ 0 ;1
|
||||
PNG_SIMPLIFIED_WRITE_SUPPORTED equ 1
|
||||
PNG_STDIO_SUPPORTED equ 1
|
||||
PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED equ 1
|
||||
PNG_TEXT_SUPPORTED equ 0
|
||||
PNG_TIME_RFC1123_SUPPORTED equ 1
|
||||
PNG_UNKNOWN_CHUNKS_SUPPORTED equ 1
|
||||
PNG_USER_CHUNKS_SUPPORTED equ 1
|
||||
PNG_USER_LIMITS_SUPPORTED equ 1
|
||||
PNG_USER_MEM_SUPPORTED equ 1
|
||||
PNG_USER_TRANSFORM_INFO_SUPPORTED equ 1
|
||||
PNG_USER_TRANSFORM_PTR_SUPPORTED equ 1
|
||||
PNG_WARNINGS_SUPPORTED equ 0
|
||||
PNG_WRITE_16BIT_SUPPORTED equ 1
|
||||
PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED equ 1
|
||||
PNG_WRITE_BGR_SUPPORTED equ 1
|
||||
PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 1
|
||||
PNG_WRITE_COMPRESSED_TEXT_SUPPORTED equ 1
|
||||
PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED equ 1
|
||||
PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED equ 0
|
||||
PNG_WRITE_FILLER_SUPPORTED equ 1
|
||||
PNG_WRITE_FILTER_SUPPORTED equ 1
|
||||
PNG_WRITE_FLUSH_SUPPORTED equ 1
|
||||
PNG_WRITE_GET_PALETTE_MAX_SUPPORTED equ 1
|
||||
PNG_WRITE_INTERLACING_SUPPORTED equ 0
|
||||
PNG_WRITE_INT_FUNCTIONS_SUPPORTED equ 1
|
||||
PNG_WRITE_INVERT_ALPHA_SUPPORTED equ 1
|
||||
PNG_WRITE_INVERT_SUPPORTED equ 1
|
||||
PNG_WRITE_OPTIMIZE_CMF_SUPPORTED equ 1
|
||||
PNG_WRITE_PACKSWAP_SUPPORTED equ 1
|
||||
PNG_WRITE_PACK_SUPPORTED equ 1
|
||||
PNG_WRITE_SHIFT_SUPPORTED equ 1
|
||||
PNG_WRITE_SUPPORTED equ 1
|
||||
PNG_WRITE_SWAP_ALPHA_SUPPORTED equ 1
|
||||
PNG_WRITE_SWAP_SUPPORTED equ 1
|
||||
PNG_WRITE_TEXT_SUPPORTED equ 0
|
||||
PNG_WRITE_TRANSFORMS_SUPPORTED equ 1
|
||||
PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED equ 0
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED equ 1
|
||||
PNG_WRITE_WEIGHTED_FILTER_SUPPORTED equ 1
|
||||
PNG_WRITE_bKGD_SUPPORTED equ 0
|
||||
PNG_WRITE_cHRM_SUPPORTED equ 0
|
||||
PNG_WRITE_gAMA_SUPPORTED equ 0
|
||||
PNG_WRITE_hIST_SUPPORTED equ 0
|
||||
PNG_WRITE_iCCP_SUPPORTED equ 0
|
||||
PNG_WRITE_iTXt_SUPPORTED equ 0
|
||||
PNG_WRITE_oFFs_SUPPORTED equ 0
|
||||
PNG_WRITE_pCAL_SUPPORTED equ 0
|
||||
PNG_WRITE_pHYs_SUPPORTED equ 0
|
||||
PNG_WRITE_sBIT_SUPPORTED equ 0
|
||||
PNG_WRITE_sCAL_SUPPORTED equ 0
|
||||
PNG_WRITE_sPLT_SUPPORTED equ 0
|
||||
PNG_WRITE_sRGB_SUPPORTED equ 0
|
||||
PNG_WRITE_tEXt_SUPPORTED equ 0
|
||||
PNG_WRITE_tIME_SUPPORTED equ 0
|
||||
PNG_WRITE_tRNS_SUPPORTED equ 0
|
||||
PNG_WRITE_zTXt_SUPPORTED equ 0
|
||||
PNG_bKGD_SUPPORTED equ 0
|
||||
PNG_cHRM_SUPPORTED equ 0
|
||||
PNG_gAMA_SUPPORTED equ 0
|
||||
PNG_hIST_SUPPORTED equ 0
|
||||
PNG_iCCP_SUPPORTED equ 0
|
||||
PNG_iTXt_SUPPORTED equ 0
|
||||
PNG_oFFs_SUPPORTED equ 0
|
||||
PNG_pCAL_SUPPORTED equ 0
|
||||
PNG_pHYs_SUPPORTED equ 0
|
||||
PNG_sBIT_SUPPORTED equ 0
|
||||
PNG_sCAL_SUPPORTED equ 0
|
||||
PNG_sPLT_SUPPORTED equ 0
|
||||
PNG_sRGB_SUPPORTED equ 0
|
||||
PNG_tEXt_SUPPORTED equ 0
|
||||
PNG_tIME_SUPPORTED equ 0
|
||||
PNG_tRNS_SUPPORTED equ 0
|
||||
PNG_zTXt_SUPPORTED equ 0
|
||||
; end of options
|
||||
; settings
|
||||
PNG_API_RULE equ 0
|
||||
PNG_DEFAULT_READ_MACROS equ 1
|
||||
PNG_GAMMA_THRESHOLD_FIXED equ 5000
|
||||
PNG_ZBUF_SIZE equ 8192
|
||||
PNG_IDAT_READ_SIZE equ PNG_ZBUF_SIZE
|
||||
PNG_INFLATE_BUF_SIZE equ 1024
|
||||
PNG_MAX_GAMMA_8 equ 11
|
||||
PNG_QUANTIZE_BLUE_BITS equ 5
|
||||
PNG_QUANTIZE_GREEN_BITS equ 5
|
||||
PNG_QUANTIZE_RED_BITS equ 5
|
||||
PNG_TEXT_Z_DEFAULT_COMPRESSION equ (-1)
|
||||
PNG_TEXT_Z_DEFAULT_STRATEGY equ 0
|
||||
PNG_USER_CHUNK_CACHE_MAX equ 1000
|
||||
PNG_USER_CHUNK_MALLOC_MAX equ 8000000
|
||||
PNG_USER_HEIGHT_MAX equ 1000000
|
||||
PNG_USER_WIDTH_MAX equ 1000000
|
||||
PNG_ZLIB_VERNUM equ 0 ;unknown
|
||||
PNG_Z_DEFAULT_COMPRESSION equ (-1)
|
||||
PNG_Z_DEFAULT_NOFILTER_STRATEGY equ 0
|
||||
PNG_Z_DEFAULT_STRATEGY equ 1
|
||||
PNG_sCAL_PRECISION equ 5
|
||||
PNG_sRGB_PROFILE_CHECKS equ 2
|
||||
; end of settings
|
||||
; libpng 1.6.25 STANDARD API DEFINITION
|
||||
|
||||
; pnglibconf.inc - library build configuration
|
||||
|
||||
; Libpng version 1.6.25 - September 1, 2016
|
||||
|
||||
; Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
|
||||
; This code is released under the libpng license.
|
||||
; For conditions of distribution and use, see the disclaimer
|
||||
; and license in png.inc
|
||||
|
||||
; pnglibconf.inc
|
||||
; Machine generated file: DO NOT EDIT
|
||||
; Derived from: scripts/pnglibconf.dfa
|
||||
|
||||
; options
|
||||
PNG_16BIT_SUPPORTED equ 1
|
||||
PNG_ALIGNED_MEMORY_SUPPORTED equ 1
|
||||
;/*#undef PNG_ARM_NEON_API_SUPPORTED*/
|
||||
;/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||
PNG_BENIGN_ERRORS_SUPPORTED equ 1
|
||||
PNG_BENIGN_READ_ERRORS_SUPPORTED equ 1
|
||||
;/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||
PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED equ 1
|
||||
PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 1
|
||||
PNG_COLORSPACE_SUPPORTED equ 1
|
||||
PNG_CONSOLE_IO_SUPPORTED equ 1
|
||||
PNG_CONVERT_tIME_SUPPORTED equ 1
|
||||
PNG_EASY_ACCESS_SUPPORTED equ 1
|
||||
;/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
|
||||
PNG_ERROR_TEXT_SUPPORTED equ 1
|
||||
PNG_FIXED_POINT_SUPPORTED equ 1
|
||||
PNG_FLOATING_ARITHMETIC_SUPPORTED equ 1
|
||||
PNG_FLOATING_POINT_SUPPORTED equ 1
|
||||
PNG_FORMAT_AFIRST_SUPPORTED equ 1
|
||||
PNG_FORMAT_BGR_SUPPORTED equ 1
|
||||
PNG_GAMMA_SUPPORTED equ 1
|
||||
PNG_GET_PALETTE_MAX_SUPPORTED equ 1
|
||||
PNG_HANDLE_AS_UNKNOWN_SUPPORTED equ 1
|
||||
PNG_INCH_CONVERSIONS_SUPPORTED equ 1
|
||||
PNG_INFO_IMAGE_SUPPORTED equ 1
|
||||
PNG_IO_STATE_SUPPORTED equ 1
|
||||
PNG_MNG_FEATURES_SUPPORTED equ 0
|
||||
PNG_POINTER_INDEXING_SUPPORTED equ 1
|
||||
PNG_PROGRESSIVE_READ_SUPPORTED equ 0
|
||||
PNG_READ_16BIT_SUPPORTED equ 0
|
||||
PNG_READ_ALPHA_MODE_SUPPORTED equ 0
|
||||
PNG_READ_ANCILLARY_CHUNKS_SUPPORTED equ 0
|
||||
PNG_READ_BACKGROUND_SUPPORTED equ 0
|
||||
PNG_READ_BGR_SUPPORTED equ 0
|
||||
PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 0
|
||||
PNG_READ_COMPOSITE_NODIV_SUPPORTED equ 0
|
||||
PNG_READ_COMPRESSED_TEXT_SUPPORTED equ 0
|
||||
PNG_READ_EXPAND_16_SUPPORTED equ 0
|
||||
PNG_READ_EXPAND_SUPPORTED equ 0
|
||||
PNG_READ_FILLER_SUPPORTED equ 0
|
||||
PNG_READ_GAMMA_SUPPORTED equ 0
|
||||
PNG_READ_GET_PALETTE_MAX_SUPPORTED equ 0
|
||||
PNG_READ_GRAY_TO_RGB_SUPPORTED equ 0
|
||||
PNG_READ_INTERLACING_SUPPORTED equ 0
|
||||
PNG_READ_INT_FUNCTIONS_SUPPORTED equ 0
|
||||
PNG_READ_INVERT_ALPHA_SUPPORTED equ 0
|
||||
PNG_READ_INVERT_SUPPORTED equ 0
|
||||
PNG_READ_OPT_PLTE_SUPPORTED equ 0
|
||||
PNG_READ_PACKSWAP_SUPPORTED equ 0
|
||||
PNG_READ_PACK_SUPPORTED equ 0
|
||||
PNG_READ_QUANTIZE_SUPPORTED equ 0
|
||||
PNG_READ_RGB_TO_GRAY_SUPPORTED equ 0
|
||||
PNG_READ_SCALE_16_TO_8_SUPPORTED equ 0
|
||||
PNG_READ_SHIFT_SUPPORTED equ 0
|
||||
PNG_READ_STRIP_16_TO_8_SUPPORTED equ 0
|
||||
PNG_READ_STRIP_ALPHA_SUPPORTED equ 0
|
||||
PNG_READ_SUPPORTED equ 0
|
||||
PNG_READ_SWAP_ALPHA_SUPPORTED equ 0
|
||||
PNG_READ_SWAP_SUPPORTED equ 0
|
||||
PNG_READ_TEXT_SUPPORTED equ 0
|
||||
PNG_READ_TRANSFORMS_SUPPORTED equ 0
|
||||
PNG_READ_UNKNOWN_CHUNKS_SUPPORTED equ 0
|
||||
PNG_READ_USER_CHUNKS_SUPPORTED equ 0
|
||||
PNG_READ_USER_TRANSFORM_SUPPORTED equ 0
|
||||
PNG_READ_bKGD_SUPPORTED equ 0
|
||||
PNG_READ_cHRM_SUPPORTED equ 0
|
||||
PNG_READ_gAMA_SUPPORTED equ 0
|
||||
PNG_READ_hIST_SUPPORTED equ 0
|
||||
PNG_READ_iCCP_SUPPORTED equ 0
|
||||
PNG_READ_iTXt_SUPPORTED equ 0
|
||||
PNG_READ_oFFs_SUPPORTED equ 0
|
||||
PNG_READ_pCAL_SUPPORTED equ 0
|
||||
PNG_READ_pHYs_SUPPORTED equ 0
|
||||
PNG_READ_sBIT_SUPPORTED equ 0
|
||||
PNG_READ_sCAL_SUPPORTED equ 0
|
||||
PNG_READ_sPLT_SUPPORTED equ 0
|
||||
PNG_READ_sRGB_SUPPORTED equ 0
|
||||
PNG_READ_tEXt_SUPPORTED equ 0
|
||||
PNG_READ_tIME_SUPPORTED equ 0
|
||||
PNG_READ_tRNS_SUPPORTED equ 0
|
||||
PNG_READ_zTXt_SUPPORTED equ 0
|
||||
PNG_SAVE_INT_32_SUPPORTED equ 1
|
||||
PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED equ 1
|
||||
PNG_SEQUENTIAL_READ_SUPPORTED equ 1
|
||||
PNG_SETJMP_SUPPORTED equ 0 ;1 ;setjmp.h — заголовочный файл стандартной библиотеки языка Си
|
||||
PNG_SET_OPTION_SUPPORTED equ 1
|
||||
PNG_SET_UNKNOWN_CHUNKS_SUPPORTED equ 1
|
||||
PNG_SET_USER_LIMITS_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_READ_BGR_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_READ_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED equ 1
|
||||
PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED equ 0 ;1
|
||||
PNG_SIMPLIFIED_WRITE_SUPPORTED equ 1
|
||||
PNG_STDIO_SUPPORTED equ 1
|
||||
PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED equ 1
|
||||
PNG_TEXT_SUPPORTED equ 0
|
||||
PNG_TIME_RFC1123_SUPPORTED equ 1
|
||||
PNG_UNKNOWN_CHUNKS_SUPPORTED equ 1
|
||||
PNG_USER_CHUNKS_SUPPORTED equ 1
|
||||
PNG_USER_LIMITS_SUPPORTED equ 1
|
||||
PNG_USER_MEM_SUPPORTED equ 1
|
||||
PNG_USER_TRANSFORM_INFO_SUPPORTED equ 1
|
||||
PNG_USER_TRANSFORM_PTR_SUPPORTED equ 1
|
||||
PNG_WARNINGS_SUPPORTED equ 0
|
||||
PNG_WRITE_16BIT_SUPPORTED equ 1
|
||||
PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED equ 1
|
||||
PNG_WRITE_BGR_SUPPORTED equ 1
|
||||
PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED equ 1
|
||||
PNG_WRITE_COMPRESSED_TEXT_SUPPORTED equ 1
|
||||
PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED equ 1
|
||||
PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED equ 0
|
||||
PNG_WRITE_FILLER_SUPPORTED equ 1
|
||||
PNG_WRITE_FILTER_SUPPORTED equ 1
|
||||
PNG_WRITE_FLUSH_SUPPORTED equ 1
|
||||
PNG_WRITE_GET_PALETTE_MAX_SUPPORTED equ 1
|
||||
PNG_WRITE_INTERLACING_SUPPORTED equ 0
|
||||
PNG_WRITE_INT_FUNCTIONS_SUPPORTED equ 1
|
||||
PNG_WRITE_INVERT_ALPHA_SUPPORTED equ 1
|
||||
PNG_WRITE_INVERT_SUPPORTED equ 1
|
||||
PNG_WRITE_OPTIMIZE_CMF_SUPPORTED equ 1
|
||||
PNG_WRITE_PACKSWAP_SUPPORTED equ 1
|
||||
PNG_WRITE_PACK_SUPPORTED equ 1
|
||||
PNG_WRITE_SHIFT_SUPPORTED equ 1
|
||||
PNG_WRITE_SUPPORTED equ 1
|
||||
PNG_WRITE_SWAP_ALPHA_SUPPORTED equ 1
|
||||
PNG_WRITE_SWAP_SUPPORTED equ 1
|
||||
PNG_WRITE_TEXT_SUPPORTED equ 0
|
||||
PNG_WRITE_TRANSFORMS_SUPPORTED equ 1
|
||||
PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED equ 0
|
||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED equ 1
|
||||
PNG_WRITE_WEIGHTED_FILTER_SUPPORTED equ 1
|
||||
PNG_WRITE_bKGD_SUPPORTED equ 0
|
||||
PNG_WRITE_cHRM_SUPPORTED equ 0
|
||||
PNG_WRITE_gAMA_SUPPORTED equ 0
|
||||
PNG_WRITE_hIST_SUPPORTED equ 0
|
||||
PNG_WRITE_iCCP_SUPPORTED equ 0
|
||||
PNG_WRITE_iTXt_SUPPORTED equ 0
|
||||
PNG_WRITE_oFFs_SUPPORTED equ 0
|
||||
PNG_WRITE_pCAL_SUPPORTED equ 0
|
||||
PNG_WRITE_pHYs_SUPPORTED equ 0
|
||||
PNG_WRITE_sBIT_SUPPORTED equ 0
|
||||
PNG_WRITE_sCAL_SUPPORTED equ 0
|
||||
PNG_WRITE_sPLT_SUPPORTED equ 0
|
||||
PNG_WRITE_sRGB_SUPPORTED equ 0
|
||||
PNG_WRITE_tEXt_SUPPORTED equ 0
|
||||
PNG_WRITE_tIME_SUPPORTED equ 0
|
||||
PNG_WRITE_tRNS_SUPPORTED equ 0
|
||||
PNG_WRITE_zTXt_SUPPORTED equ 0
|
||||
PNG_bKGD_SUPPORTED equ 0
|
||||
PNG_cHRM_SUPPORTED equ 0
|
||||
PNG_gAMA_SUPPORTED equ 0
|
||||
PNG_hIST_SUPPORTED equ 0
|
||||
PNG_iCCP_SUPPORTED equ 0
|
||||
PNG_iTXt_SUPPORTED equ 0
|
||||
PNG_oFFs_SUPPORTED equ 0
|
||||
PNG_pCAL_SUPPORTED equ 0
|
||||
PNG_pHYs_SUPPORTED equ 0
|
||||
PNG_sBIT_SUPPORTED equ 0
|
||||
PNG_sCAL_SUPPORTED equ 0
|
||||
PNG_sPLT_SUPPORTED equ 0
|
||||
PNG_sRGB_SUPPORTED equ 0
|
||||
PNG_tEXt_SUPPORTED equ 0
|
||||
PNG_tIME_SUPPORTED equ 0
|
||||
PNG_tRNS_SUPPORTED equ 0
|
||||
PNG_zTXt_SUPPORTED equ 0
|
||||
; end of options
|
||||
; settings
|
||||
PNG_API_RULE equ 0
|
||||
PNG_DEFAULT_READ_MACROS equ 1
|
||||
PNG_GAMMA_THRESHOLD_FIXED equ 5000
|
||||
PNG_ZBUF_SIZE equ 8192
|
||||
PNG_IDAT_READ_SIZE equ PNG_ZBUF_SIZE
|
||||
PNG_INFLATE_BUF_SIZE equ 1024
|
||||
PNG_MAX_GAMMA_8 equ 11
|
||||
PNG_QUANTIZE_BLUE_BITS equ 5
|
||||
PNG_QUANTIZE_GREEN_BITS equ 5
|
||||
PNG_QUANTIZE_RED_BITS equ 5
|
||||
PNG_TEXT_Z_DEFAULT_COMPRESSION equ (-1)
|
||||
PNG_TEXT_Z_DEFAULT_STRATEGY equ 0
|
||||
PNG_USER_CHUNK_CACHE_MAX equ 1000
|
||||
PNG_USER_CHUNK_MALLOC_MAX equ 8000000
|
||||
PNG_USER_HEIGHT_MAX equ 1000000
|
||||
PNG_USER_WIDTH_MAX equ 1000000
|
||||
PNG_ZLIB_VERNUM equ 0 ;unknown
|
||||
PNG_Z_DEFAULT_COMPRESSION equ (-1)
|
||||
PNG_Z_DEFAULT_NOFILTER_STRATEGY equ 0
|
||||
PNG_Z_DEFAULT_STRATEGY equ 1
|
||||
PNG_sCAL_PRECISION equ 5
|
||||
PNG_sRGB_PROFILE_CHECKS equ 2
|
||||
; end of settings
|
||||
|
@ -1,303 +1,303 @@
|
||||
|
||||
; pngmem.asm - stub functions for memory allocation
|
||||
|
||||
; Last changed in libpng 1.6.24 [August 4, 2016%]
|
||||
; Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
||||
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
||||
; This code is released under the libpng license.
|
||||
; For conditions of distribution and use, see the disclaimer
|
||||
; and license in png.inc
|
||||
|
||||
; This file provides a location for all memory allocation. Users who
|
||||
; need special memory handling are expected to supply replacement
|
||||
; functions for png_malloc() and png_free(), and to use
|
||||
; png_create_read_struct_2() and png_create_write_struct_2() to
|
||||
; identify the replacement functions.
|
||||
|
||||
; Free a png_struct
|
||||
;void (png_structrp png_ptr)
|
||||
align 4
|
||||
proc png_destroy_png_struct uses eax ecx edi esi, png_ptr:dword
|
||||
locals
|
||||
dummy_struct png_struct
|
||||
endl
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..!=0)
|
||||
; png_free might call png_error and may certainly call
|
||||
; png_get_mem_ptr, so fake a temporary png_struct to support this.
|
||||
|
||||
mov ecx,sizeof.png_struct
|
||||
mov esi,edi
|
||||
mov edi,ebp
|
||||
sub edi,ecx
|
||||
rep movsb ;dummy_struct = *png_ptr
|
||||
mov edi,[png_ptr]
|
||||
xor eax,eax
|
||||
mov ecx,sizeof.png_struct
|
||||
rep stosb ;memset(png_ptr, 0, (sizeof *png_ptr))
|
||||
mov esi,ebp
|
||||
sub esi,sizeof.png_struct
|
||||
stdcall png_free, esi, [png_ptr]
|
||||
|
||||
if PNG_SETJMP_SUPPORTED eq 1
|
||||
; We may have a jmp_buf left to deallocate.
|
||||
stdcall png_free_jmpbuf, esi
|
||||
end if
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
; Allocate memory. For reasonable files, size should never exceed
|
||||
; 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
|
||||
; need to allocate exactly 64K, so whatever you call here must
|
||||
; have the ability to do that.
|
||||
|
||||
;voidp (const_structrp png_ptr, png_alloc_size_t size)
|
||||
align 4
|
||||
proc png_calloc uses ebx ecx edi, png_ptr:dword, size:dword
|
||||
stdcall png_malloc, [png_ptr], [size]
|
||||
|
||||
cmp eax,0
|
||||
je @f ;if (..!=0)
|
||||
mov ebx,eax
|
||||
mov edi,eax
|
||||
mov ecx,[size]
|
||||
xor eax,eax
|
||||
rep stosb ;memset(ret, 0, size)
|
||||
mov eax,ebx
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
; 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.
|
||||
; Checking and error handling must happen outside this routine; it returns NULL
|
||||
; if the allocation cannot be done (for any reason.)
|
||||
|
||||
;voidp (const_structrp png_ptr, png_alloc_size_t size)
|
||||
align 4
|
||||
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
|
||||
; 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
|
||||
; called with big numbers.
|
||||
|
||||
; Some compilers complain that this is always true. However, it
|
||||
; can be false when integer overflow happens.
|
||||
|
||||
cmp dword[size],0
|
||||
jle .end0
|
||||
cmp dword[size],PNG_SIZE_MAX
|
||||
jg .end0 ; if (..>.. && ..<=..)
|
||||
if PNG_MAX_MALLOC_64K eq 1
|
||||
cmp dword[size],65536
|
||||
jg .end0
|
||||
end if
|
||||
if PNG_USER_MEM_SUPPORTED eq 1
|
||||
mov ebx,[png_ptr]
|
||||
cmp ebx,0
|
||||
je @f
|
||||
cmp dword[ebx+png_struct.malloc_fn],0
|
||||
je @f ;if (..!=0 && ..!=0)
|
||||
stdcall [ebx+png_struct.malloc_fn], ebx, [size]
|
||||
jmp .end_f
|
||||
@@: ;else
|
||||
end if
|
||||
;stdcall [mem.alloc], [size]
|
||||
mcall SF_SYS_MISC, SSF_MEM_ALLOC, [size]
|
||||
jmp .end_f ;checked for truncation above
|
||||
.end0: ;else
|
||||
xor eax,eax
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; 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
|
||||
; png_malloc_array.
|
||||
|
||||
;voidp (const_structrp png_ptr, int nelements, size_t element_size)
|
||||
align 4
|
||||
proc png_malloc_array_checked, png_ptr:dword, nelements:dword, element_size:dword
|
||||
; png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||
|
||||
; if (req <= PNG_SIZE_MAX/element_size)
|
||||
; return png_malloc_base(png_ptr, req * element_size);
|
||||
|
||||
; The failure case when the request is too large
|
||||
xor eax,eax
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
;voidp (const_structrp png_ptr, int nelements, size_t element_size)
|
||||
align 4
|
||||
proc png_malloc_array, png_ptr:dword, nelements:dword, element_size:dword
|
||||
; if (nelements <= 0 || element_size == 0)
|
||||
; png_error(png_ptr, "internal error: array alloc");
|
||||
|
||||
stdcall png_malloc_array_checked, [png_ptr], [nelements], [element_size]
|
||||
ret
|
||||
endp
|
||||
|
||||
;voidp (const_structrp png_ptr, const_voidp old_array,
|
||||
; int old_elements, int add_elements, size_t element_size)
|
||||
align 4
|
||||
proc png_realloc_array, png_ptr:dword, old_array:dword, old_elements:dword, add_elements:dword, element_size:dword
|
||||
; These are internal errors:
|
||||
; if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
|
||||
; (old_array == NULL && old_elements > 0))
|
||||
; png_error(png_ptr, "internal error: array realloc");
|
||||
|
||||
; Check for overflow on the elements count (so the caller does not have to
|
||||
; check.)
|
||||
|
||||
; if (add_elements <= INT_MAX - old_elements)
|
||||
; {
|
||||
; voidp new_array = png_malloc_array_checked(png_ptr,
|
||||
; old_elements+add_elements, element_size);
|
||||
;
|
||||
; if (new_array != NULL)
|
||||
; {
|
||||
; Because png_malloc_array worked the size calculations below cannot
|
||||
; overflow.
|
||||
|
||||
; if (old_elements > 0)
|
||||
; memcpy(new_array, old_array, element_size*(unsigned)old_elements);
|
||||
;
|
||||
; memset((char*)new_array + element_size*(unsigned)old_elements, 0,
|
||||
; element_size*(unsigned)add_elements);
|
||||
;
|
||||
; return new_array;
|
||||
; }
|
||||
; }
|
||||
|
||||
xor eax,eax ;error
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; 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
|
||||
; function png_malloc_default is also provided.
|
||||
|
||||
;voidp (const_structrp png_ptr, png_alloc_size_t size)
|
||||
align 4
|
||||
proc png_malloc uses edi, png_ptr:dword, size:dword
|
||||
xor eax,eax
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..==0) return 0
|
||||
|
||||
stdcall png_malloc_base, edi, [size]
|
||||
|
||||
cmp eax,0
|
||||
jne @f ;if (..==0)
|
||||
png_error edi, 'Out of memory' ;'m' means png_malloc
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
;voidp (const_structrp png_ptr, png_alloc_size_t size)
|
||||
align 4
|
||||
proc png_malloc_default uses edi, png_ptr:dword, size:dword
|
||||
xor eax,eax
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..==0) return 0
|
||||
|
||||
; Passing 'NULL' here bypasses the application provided memory handler.
|
||||
stdcall png_malloc_base, 0, [size] ;0 - use malloc
|
||||
|
||||
cmp eax,0
|
||||
jne @f ;if (..==0)
|
||||
png_error edi, 'Out of Memory' ;'M' means png_malloc_default
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
; 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
|
||||
; png_error, if it fails to allocate the requested memory.
|
||||
|
||||
;voidp (const_structrp png_ptr, png_alloc_size_t size)
|
||||
align 4
|
||||
proc png_malloc_warn uses edi, png_ptr:dword, size:dword
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je .end0 ;if (..!=0)
|
||||
stdcall png_malloc_base, edi, [size]
|
||||
cmp eax,0
|
||||
jne .end_f ;if (..!=0) return ret
|
||||
|
||||
png_warning edi, 'Out of memory'
|
||||
.end0:
|
||||
xor eax,eax
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||
; without taking any action.
|
||||
|
||||
;void (const_structrp png_ptr, voidp ptr)
|
||||
align 4
|
||||
proc png_free uses eax ebx ecx, png_ptr:dword, p2ptr:dword
|
||||
mov ebx,[png_ptr]
|
||||
cmp ebx,0
|
||||
je .end_f
|
||||
mov ecx,[p2ptr]
|
||||
cmp ecx,0
|
||||
je .end_f ;if (..==0 || ..==0) return
|
||||
|
||||
if PNG_USER_MEM_SUPPORTED eq 1
|
||||
cmp dword[ebx+png_struct.free_fn],0
|
||||
je @f ;if (..!=0)
|
||||
stdcall dword[ebx+png_struct.free_fn], ebx, [p2ptr]
|
||||
jmp .end_f
|
||||
@@: ;else
|
||||
end if
|
||||
mcall SF_SYS_MISC, SSF_MEM_FREE, [p2ptr]
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; This function is called when the application wants to use another method
|
||||
; of allocating and freeing memory.
|
||||
|
||||
;void (png_structrp png_ptr, voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
|
||||
align 4
|
||||
proc png_set_mem_fn uses eax edi, png_ptr:dword, mem_ptr:dword, malloc_fn:dword, free_fn:dword
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..!=0)
|
||||
mov eax,[mem_ptr]
|
||||
mov [edi+png_struct.mem_ptr],eax
|
||||
mov eax,[malloc_fn]
|
||||
mov [edi+png_struct.malloc_fn],eax
|
||||
mov eax,[free_fn]
|
||||
mov [edi+png_struct.free_fn],eax
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
; This function returns a pointer to the mem_ptr associated with the user
|
||||
; functions. The application should free any memory associated with this
|
||||
; pointer before png_write_destroy and png_read_destroy are called.
|
||||
|
||||
;voidp (const_structrp png_ptr)
|
||||
align 4
|
||||
proc png_get_mem_ptr uses edi, png_ptr:dword
|
||||
xor eax,eax
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..==0) return 0
|
||||
mov eax,[edi+png_struct.mem_ptr]
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
; pngmem.asm - stub functions for memory allocation
|
||||
|
||||
; Last changed in libpng 1.6.24 [August 4, 2016%]
|
||||
; Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
||||
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
||||
; This code is released under the libpng license.
|
||||
; For conditions of distribution and use, see the disclaimer
|
||||
; and license in png.inc
|
||||
|
||||
; This file provides a location for all memory allocation. Users who
|
||||
; need special memory handling are expected to supply replacement
|
||||
; functions for png_malloc() and png_free(), and to use
|
||||
; png_create_read_struct_2() and png_create_write_struct_2() to
|
||||
; identify the replacement functions.
|
||||
|
||||
; Free a png_struct
|
||||
;void (png_structrp png_ptr)
|
||||
align 4
|
||||
proc png_destroy_png_struct uses eax ecx edi esi, png_ptr:dword
|
||||
locals
|
||||
dummy_struct png_struct
|
||||
endl
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..!=0)
|
||||
; png_free might call png_error and may certainly call
|
||||
; png_get_mem_ptr, so fake a temporary png_struct to support this.
|
||||
|
||||
mov ecx,sizeof.png_struct
|
||||
mov esi,edi
|
||||
mov edi,ebp
|
||||
sub edi,ecx
|
||||
rep movsb ;dummy_struct = *png_ptr
|
||||
mov edi,[png_ptr]
|
||||
xor eax,eax
|
||||
mov ecx,sizeof.png_struct
|
||||
rep stosb ;memset(png_ptr, 0, (sizeof *png_ptr))
|
||||
mov esi,ebp
|
||||
sub esi,sizeof.png_struct
|
||||
stdcall png_free, esi, [png_ptr]
|
||||
|
||||
if PNG_SETJMP_SUPPORTED eq 1
|
||||
; We may have a jmp_buf left to deallocate.
|
||||
stdcall png_free_jmpbuf, esi
|
||||
end if
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
; Allocate memory. For reasonable files, size should never exceed
|
||||
; 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
|
||||
; need to allocate exactly 64K, so whatever you call here must
|
||||
; have the ability to do that.
|
||||
|
||||
;voidp (const_structrp png_ptr, png_alloc_size_t size)
|
||||
align 4
|
||||
proc png_calloc uses ebx ecx edi, png_ptr:dword, size:dword
|
||||
stdcall png_malloc, [png_ptr], [size]
|
||||
|
||||
cmp eax,0
|
||||
je @f ;if (..!=0)
|
||||
mov ebx,eax
|
||||
mov edi,eax
|
||||
mov ecx,[size]
|
||||
xor eax,eax
|
||||
rep stosb ;memset(ret, 0, size)
|
||||
mov eax,ebx
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
; 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.
|
||||
; Checking and error handling must happen outside this routine; it returns NULL
|
||||
; if the allocation cannot be done (for any reason.)
|
||||
|
||||
;voidp (const_structrp png_ptr, png_alloc_size_t size)
|
||||
align 4
|
||||
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
|
||||
; 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
|
||||
; called with big numbers.
|
||||
|
||||
; Some compilers complain that this is always true. However, it
|
||||
; can be false when integer overflow happens.
|
||||
|
||||
cmp dword[size],0
|
||||
jle .end0
|
||||
cmp dword[size],PNG_SIZE_MAX
|
||||
jg .end0 ; if (..>.. && ..<=..)
|
||||
if PNG_MAX_MALLOC_64K eq 1
|
||||
cmp dword[size],65536
|
||||
jg .end0
|
||||
end if
|
||||
if PNG_USER_MEM_SUPPORTED eq 1
|
||||
mov ebx,[png_ptr]
|
||||
cmp ebx,0
|
||||
je @f
|
||||
cmp dword[ebx+png_struct.malloc_fn],0
|
||||
je @f ;if (..!=0 && ..!=0)
|
||||
stdcall [ebx+png_struct.malloc_fn], ebx, [size]
|
||||
jmp .end_f
|
||||
@@: ;else
|
||||
end if
|
||||
;stdcall [mem.alloc], [size]
|
||||
mcall SF_SYS_MISC, SSF_MEM_ALLOC, [size]
|
||||
jmp .end_f ;checked for truncation above
|
||||
.end0: ;else
|
||||
xor eax,eax
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; 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
|
||||
; png_malloc_array.
|
||||
|
||||
;voidp (const_structrp png_ptr, int nelements, size_t element_size)
|
||||
align 4
|
||||
proc png_malloc_array_checked, png_ptr:dword, nelements:dword, element_size:dword
|
||||
; png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||
|
||||
; if (req <= PNG_SIZE_MAX/element_size)
|
||||
; return png_malloc_base(png_ptr, req * element_size);
|
||||
|
||||
; The failure case when the request is too large
|
||||
xor eax,eax
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
;voidp (const_structrp png_ptr, int nelements, size_t element_size)
|
||||
align 4
|
||||
proc png_malloc_array, png_ptr:dword, nelements:dword, element_size:dword
|
||||
; if (nelements <= 0 || element_size == 0)
|
||||
; png_error(png_ptr, "internal error: array alloc");
|
||||
|
||||
stdcall png_malloc_array_checked, [png_ptr], [nelements], [element_size]
|
||||
ret
|
||||
endp
|
||||
|
||||
;voidp (const_structrp png_ptr, const_voidp old_array,
|
||||
; int old_elements, int add_elements, size_t element_size)
|
||||
align 4
|
||||
proc png_realloc_array, png_ptr:dword, old_array:dword, old_elements:dword, add_elements:dword, element_size:dword
|
||||
; These are internal errors:
|
||||
; if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
|
||||
; (old_array == NULL && old_elements > 0))
|
||||
; png_error(png_ptr, "internal error: array realloc");
|
||||
|
||||
; Check for overflow on the elements count (so the caller does not have to
|
||||
; check.)
|
||||
|
||||
; if (add_elements <= INT_MAX - old_elements)
|
||||
; {
|
||||
; voidp new_array = png_malloc_array_checked(png_ptr,
|
||||
; old_elements+add_elements, element_size);
|
||||
;
|
||||
; if (new_array != NULL)
|
||||
; {
|
||||
; Because png_malloc_array worked the size calculations below cannot
|
||||
; overflow.
|
||||
|
||||
; if (old_elements > 0)
|
||||
; memcpy(new_array, old_array, element_size*(unsigned)old_elements);
|
||||
;
|
||||
; memset((char*)new_array + element_size*(unsigned)old_elements, 0,
|
||||
; element_size*(unsigned)add_elements);
|
||||
;
|
||||
; return new_array;
|
||||
; }
|
||||
; }
|
||||
|
||||
xor eax,eax ;error
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; 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
|
||||
; function png_malloc_default is also provided.
|
||||
|
||||
;voidp (const_structrp png_ptr, png_alloc_size_t size)
|
||||
align 4
|
||||
proc png_malloc uses edi, png_ptr:dword, size:dword
|
||||
xor eax,eax
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..==0) return 0
|
||||
|
||||
stdcall png_malloc_base, edi, [size]
|
||||
|
||||
cmp eax,0
|
||||
jne @f ;if (..==0)
|
||||
png_error edi, 'Out of memory' ;'m' means png_malloc
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
;voidp (const_structrp png_ptr, png_alloc_size_t size)
|
||||
align 4
|
||||
proc png_malloc_default uses edi, png_ptr:dword, size:dword
|
||||
xor eax,eax
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..==0) return 0
|
||||
|
||||
; Passing 'NULL' here bypasses the application provided memory handler.
|
||||
stdcall png_malloc_base, 0, [size] ;0 - use malloc
|
||||
|
||||
cmp eax,0
|
||||
jne @f ;if (..==0)
|
||||
png_error edi, 'Out of Memory' ;'M' means png_malloc_default
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
; 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
|
||||
; png_error, if it fails to allocate the requested memory.
|
||||
|
||||
;voidp (const_structrp png_ptr, png_alloc_size_t size)
|
||||
align 4
|
||||
proc png_malloc_warn uses edi, png_ptr:dword, size:dword
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je .end0 ;if (..!=0)
|
||||
stdcall png_malloc_base, edi, [size]
|
||||
cmp eax,0
|
||||
jne .end_f ;if (..!=0) return ret
|
||||
|
||||
png_warning edi, 'Out of memory'
|
||||
.end0:
|
||||
xor eax,eax
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; Free a pointer allocated by png_malloc(). If ptr is NULL, return
|
||||
; without taking any action.
|
||||
|
||||
;void (const_structrp png_ptr, voidp ptr)
|
||||
align 4
|
||||
proc png_free uses eax ebx ecx, png_ptr:dword, p2ptr:dword
|
||||
mov ebx,[png_ptr]
|
||||
cmp ebx,0
|
||||
je .end_f
|
||||
mov ecx,[p2ptr]
|
||||
cmp ecx,0
|
||||
je .end_f ;if (..==0 || ..==0) return
|
||||
|
||||
if PNG_USER_MEM_SUPPORTED eq 1
|
||||
cmp dword[ebx+png_struct.free_fn],0
|
||||
je @f ;if (..!=0)
|
||||
stdcall dword[ebx+png_struct.free_fn], ebx, [p2ptr]
|
||||
jmp .end_f
|
||||
@@: ;else
|
||||
end if
|
||||
mcall SF_SYS_MISC, SSF_MEM_FREE, [p2ptr]
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; This function is called when the application wants to use another method
|
||||
; of allocating and freeing memory.
|
||||
|
||||
;void (png_structrp png_ptr, voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)
|
||||
align 4
|
||||
proc png_set_mem_fn uses eax edi, png_ptr:dword, mem_ptr:dword, malloc_fn:dword, free_fn:dword
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..!=0)
|
||||
mov eax,[mem_ptr]
|
||||
mov [edi+png_struct.mem_ptr],eax
|
||||
mov eax,[malloc_fn]
|
||||
mov [edi+png_struct.malloc_fn],eax
|
||||
mov eax,[free_fn]
|
||||
mov [edi+png_struct.free_fn],eax
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
; This function returns a pointer to the mem_ptr associated with the user
|
||||
; functions. The application should free any memory associated with this
|
||||
; pointer before png_write_destroy and png_read_destroy are called.
|
||||
|
||||
;voidp (const_structrp png_ptr)
|
||||
align 4
|
||||
proc png_get_mem_ptr uses edi, png_ptr:dword
|
||||
xor eax,eax
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..==0) return 0
|
||||
mov eax,[edi+png_struct.mem_ptr]
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
|
@ -1,306 +1,306 @@
|
||||
;
|
||||
; Options
|
||||
;
|
||||
|
||||
PNG_RELEASE_BUILD equ 1
|
||||
|
||||
;---
|
||||
; Various modes of operation. Note that after an init, mode is set to
|
||||
; zero automatically when the structure is created. Three of these
|
||||
; are defined in png.inc because they need to be visible to applications
|
||||
; that call png_set_unknown_chunk().
|
||||
|
||||
;PNG_HAVE_IHDR 0x01 (defined in png.inc)
|
||||
;PNG_HAVE_PLTE 0x02 (defined in png.inc)
|
||||
PNG_HAVE_IDAT equ 0x04
|
||||
;PNG_AFTER_IDAT 0x08 (defined in png.inc)
|
||||
PNG_HAVE_IEND equ 0x10
|
||||
;0x20 (unused)
|
||||
;0x40 (unused)
|
||||
;0x80 (unused)
|
||||
PNG_HAVE_CHUNK_HEADER equ 0x100
|
||||
PNG_WROTE_tIME equ 0x200
|
||||
PNG_WROTE_INFO_BEFORE_PLTE equ 0x400
|
||||
PNG_BACKGROUND_IS_GRAY equ 0x800
|
||||
PNG_HAVE_PNG_SIGNATURE equ 0x1000
|
||||
PNG_HAVE_CHUNK_AFTER_IDAT equ 0x2000 ;Have another chunk after IDAT
|
||||
;0x4000 (unused)
|
||||
PNG_IS_READ_STRUCT equ 0x8000 ;Else is a write struct
|
||||
|
||||
; Flags for the transformations the PNG library does on the image data
|
||||
PNG_BGR equ 0x0001
|
||||
PNG_INTERLACE equ 0x0002
|
||||
PNG_PACK equ 0x0004
|
||||
PNG_SHIFT equ 0x0008
|
||||
PNG_SWAP_BYTES equ 0x0010
|
||||
PNG_INVERT_MONO equ 0x0020
|
||||
PNG_QUANTIZE equ 0x0040
|
||||
PNG_COMPOSE equ 0x0080 ;Was PNG_BACKGROUND
|
||||
PNG_BACKGROUND_EXPAND equ 0x0100
|
||||
PNG_EXPAND_16 equ 0x0200 ;Added to libpng 1.5.2
|
||||
PNG_16_TO_8 equ 0x0400 ;Becomes 'chop' in 1.5.4
|
||||
PNG_RGBA equ 0x0800
|
||||
PNG_EXPAND equ 0x1000
|
||||
PNG_GAMMA equ 0x2000
|
||||
PNG_GRAY_TO_RGB equ 0x4000
|
||||
PNG_FILLER equ 0x8000
|
||||
PNG_PACKSWAP equ 0x10000
|
||||
PNG_SWAP_ALPHA equ 0x20000
|
||||
PNG_STRIP_ALPHA equ 0x40000
|
||||
PNG_INVERT_ALPHA equ 0x80000
|
||||
PNG_USER_TRANSFORM equ 0x100000
|
||||
PNG_RGB_TO_GRAY_ERR equ 0x200000
|
||||
PNG_RGB_TO_GRAY_WARN equ 0x400000
|
||||
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_ADD_ALPHA equ 0x1000000 ;Added to libpng-1.2.7
|
||||
PNG_EXPAND_tRNS equ 0x2000000 ;Added to libpng-1.2.9
|
||||
PNG_SCALE_16_TO_8 equ 0x4000000 ;Added to libpng-1.5.4
|
||||
;0x8000000 unused
|
||||
;0x10000000 unused
|
||||
;0x20000000 unused
|
||||
;0x40000000 unused
|
||||
; Flags for png_create_struct
|
||||
PNG_STRUCT_PNG equ 0x0001
|
||||
PNG_STRUCT_INFO equ 0x0002
|
||||
|
||||
; Flags for the png_ptr->flags rather than declaring a byte for each one
|
||||
PNG_FLAG_ZLIB_CUSTOM_STRATEGY equ 0x0001
|
||||
PNG_FLAG_ZSTREAM_INITIALIZED equ 0x0002 ;Added to libpng-1.6.0
|
||||
;0x0004 unused
|
||||
PNG_FLAG_ZSTREAM_ENDED equ 0x0008 ;Added to libpng-1.6.0
|
||||
;0x0010 unused
|
||||
;0x0020 unused
|
||||
PNG_FLAG_ROW_INIT equ 0x0040
|
||||
PNG_FLAG_FILLER_AFTER equ 0x0080
|
||||
PNG_FLAG_CRC_ANCILLARY_USE equ 0x0100
|
||||
PNG_FLAG_CRC_ANCILLARY_NOWARN equ 0x0200
|
||||
PNG_FLAG_CRC_CRITICAL_USE equ 0x0400
|
||||
PNG_FLAG_CRC_CRITICAL_IGNORE equ 0x0800
|
||||
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_DETECT_UNINITIALIZED equ 0x4000 ;Added to libpng-1.5.4
|
||||
;PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000
|
||||
;PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000
|
||||
PNG_FLAG_LIBRARY_MISMATCH equ 0x20000
|
||||
PNG_FLAG_STRIP_ERROR_NUMBERS equ 0x40000
|
||||
PNG_FLAG_STRIP_ERROR_TEXT equ 0x80000
|
||||
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_ERRORS_WARN equ 0x400000 ;Added to libpng-1.6.0
|
||||
|
||||
; 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_INVERSE equ 65909
|
||||
PNG_GAMMA_sRGB_INVERSE equ 45455
|
||||
|
||||
macro PNG_ROWBYTES pixel_bits, width
|
||||
{
|
||||
local .end0
|
||||
if pixel_bits eq eax
|
||||
else
|
||||
mov eax,pixel_bits
|
||||
end if
|
||||
cmp eax,8
|
||||
jge .end0
|
||||
add eax,7
|
||||
.end0:
|
||||
shr eax,3
|
||||
imul eax,width
|
||||
}
|
||||
|
||||
; In 1.7.0 the definitions will be made public in png.inc to avoid having to
|
||||
; duplicate the same definitions in application code.
|
||||
|
||||
png_IDAT equ 'IDAT'
|
||||
png_IEND equ 'IEND'
|
||||
png_IHDR equ 'IHDR'
|
||||
png_PLTE equ 'PLTE'
|
||||
png_bKGD equ 'bKGD'
|
||||
png_cHRM equ 'cHRM'
|
||||
png_fRAc equ 'fRAc' ;registered, not defined
|
||||
png_gAMA equ 'gAMA'
|
||||
png_gIFg equ 'gIFg'
|
||||
png_gIFt equ 'gIFt' ;deprecated
|
||||
png_gIFx equ 'gIFx'
|
||||
png_hIST equ 'hIST'
|
||||
png_iCCP equ 'iCCP'
|
||||
png_iTXt equ 'iTXt'
|
||||
png_oFFs equ 'oFFs'
|
||||
png_pCAL equ 'pCAL'
|
||||
png_pHYs equ 'pHYs'
|
||||
png_sBIT equ 'sBIT'
|
||||
png_sCAL equ 'sCAL'
|
||||
png_sPLT equ 'sPLT'
|
||||
png_sRGB equ 'sRGB'
|
||||
png_sTER equ 'sTER'
|
||||
png_tEXt equ 'tEXt'
|
||||
png_tIME equ 'tIME'
|
||||
png_tRNS equ 'tRNS'
|
||||
png_zTXt equ 'zTXt'
|
||||
|
||||
;Test on flag values as defined in the spec (section 5.4):
|
||||
macro PNG_CHUNK_ANCILLARY c
|
||||
{
|
||||
mov eax,c
|
||||
shr eax,29
|
||||
and eax,1
|
||||
}
|
||||
macro PNG_CHUNK_CRITICAL c
|
||||
{
|
||||
PNG_CHUNK_ANCILLARY c
|
||||
xor eax,1
|
||||
}
|
||||
macro PNG_CHUNK_PRIVATE c
|
||||
{
|
||||
mov eax,c
|
||||
shr eax,21
|
||||
and eax,1
|
||||
}
|
||||
macro PNG_CHUNK_RESERVED c
|
||||
{
|
||||
mov eax,c
|
||||
shr eax,13
|
||||
and eax,1
|
||||
}
|
||||
macro PNG_CHUNK_SAFE_TO_COPY c
|
||||
{
|
||||
mov eax,c
|
||||
shr eax,5
|
||||
and eax,1
|
||||
}
|
||||
|
||||
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_MASK equ (PNG_FLAG_CRC_ANCILLARY_MASK or PNG_FLAG_CRC_CRITICAL_MASK)
|
||||
|
||||
macro PNG_sRGB_FROM_LINEAR linear
|
||||
{
|
||||
mov eax,linear
|
||||
shr eax,15
|
||||
shl eax,1
|
||||
add eax,png_sRGB_base
|
||||
movzx eax,word[eax]
|
||||
push ebx ecx
|
||||
mov ebx,linear
|
||||
shr ebx,15
|
||||
add ebx,png_sRGB_delta
|
||||
mov ecx,linear
|
||||
and ecx,0x7fff
|
||||
imul ecx,ebx
|
||||
shr ecx,12
|
||||
add eax,ecx
|
||||
pop ecx ebx
|
||||
shr eax,8
|
||||
;;;and eax,0xff
|
||||
}
|
||||
; 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
|
||||
; 16-bit value; it has been multiplied by 255!
|
||||
|
||||
PNG_UNEXPECTED_ZLIB_RETURN equ (-7)
|
||||
|
||||
;...
|
||||
|
||||
; Suggested size for a number buffer (enough for 64 bits and a sign!)
|
||||
PNG_NUMBER_BUFFER_SIZE equ 24
|
||||
|
||||
; These are the integer formats currently supported, the name is formed from
|
||||
; the standard printf(3) format string.
|
||||
|
||||
PNG_NUMBER_FORMAT_u equ 1 ;chose unsigned API!
|
||||
PNG_NUMBER_FORMAT_02u equ 2
|
||||
PNG_NUMBER_FORMAT_d equ 1 ;chose signed API!
|
||||
PNG_NUMBER_FORMAT_02d equ 2
|
||||
PNG_NUMBER_FORMAT_x equ 3
|
||||
PNG_NUMBER_FORMAT_02x equ 4
|
||||
PNG_NUMBER_FORMAT_fixed equ 5 ;choose the signed API
|
||||
|
||||
; New defines and members adding in libpng-1.5.4
|
||||
PNG_WARNING_PARAMETER_SIZE equ 32
|
||||
PNG_WARNING_PARAMETER_COUNT equ 8 ;Maximum 9; see pngerror.asm
|
||||
|
||||
PNG_CHUNK_WARNING equ 0 ;never an error
|
||||
PNG_CHUNK_WRITE_ERROR equ 1 ;an error only on write
|
||||
PNG_CHUNK_ERROR equ 2 ;always an error
|
||||
|
||||
; ASCII to FP interfaces, currently only implemented if sCAL
|
||||
; support is required.
|
||||
|
||||
; MAX_DIGITS is actually the maximum number of characters in an sCAL
|
||||
; width or height, derived from the precision (number of significant
|
||||
; digits - a build time settable option) and assumptions about the
|
||||
; maximum ridiculous 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.
|
||||
; 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.
|
||||
|
||||
; The format of a number is defined in the PNG extensions specification
|
||||
; and this API is strictly conformant to that spec, not anyone elses!
|
||||
|
||||
; The format as a regular expression is:
|
||||
|
||||
; [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?
|
||||
|
||||
; or:
|
||||
|
||||
; [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?
|
||||
|
||||
; 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.
|
||||
|
||||
; NOTE: The dangling E problem.
|
||||
; There is a PNG valid floating point number in the following:
|
||||
|
||||
; PNG floating point numbers are not greedy.
|
||||
|
||||
; Working this out requires *TWO* character lookahead (because of the
|
||||
; 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
|
||||
; if the value were ever to be embedded in something more complex. Use
|
||||
; ANSI-C strtod if you need the lookahead.
|
||||
|
||||
; State table for the parser.
|
||||
PNG_FP_INTEGER equ 0 ;before or in integer
|
||||
PNG_FP_FRACTION equ 1 ;before or in fraction
|
||||
PNG_FP_EXPONENT equ 2 ;before or in exponent
|
||||
PNG_FP_STATE equ 3 ;mask for the above
|
||||
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_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_ANY equ 60 ;Saw any of the above 4
|
||||
|
||||
; 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_NEGATIVE equ 128 ;A negative number, including "-0"
|
||||
PNG_FP_NONZERO equ 256 ;A non-zero value
|
||||
PNG_FP_STICKY equ 448 ;The above three flags
|
||||
|
||||
; 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.)
|
||||
|
||||
PNG_FP_INVALID equ 512 ;Available for callers as a distinct value
|
||||
|
||||
; Result codes for the parser (boolean - true meants ok, false means
|
||||
; not ok yet.)
|
||||
|
||||
PNG_FP_MAYBE equ 0 ;The number may be valid in the future
|
||||
PNG_FP_OK equ 1 ;The number is valid
|
||||
|
||||
; The internal structure that png_image::opaque points to.
|
||||
struct png_control
|
||||
png_ptr dd ? ;png_structp
|
||||
info_ptr dd ? ;png_infop
|
||||
error_buf dd ? ;voidp ;Always a jmp_buf at present.
|
||||
|
||||
memory dd ? ;bytep ;Memory buffer.
|
||||
size dd ? ;png_size_t ;Size of the memory buffer.
|
||||
|
||||
for_write dd ? ;uint ;:1;Otherwise it is a read structure
|
||||
owned_file dd ? ;uint ;:1;We own the file in io_ptr
|
||||
ends
|
||||
;
|
||||
; Options
|
||||
;
|
||||
|
||||
PNG_RELEASE_BUILD equ 1
|
||||
|
||||
;---
|
||||
; Various modes of operation. Note that after an init, mode is set to
|
||||
; zero automatically when the structure is created. Three of these
|
||||
; are defined in png.inc because they need to be visible to applications
|
||||
; that call png_set_unknown_chunk().
|
||||
|
||||
;PNG_HAVE_IHDR 0x01 (defined in png.inc)
|
||||
;PNG_HAVE_PLTE 0x02 (defined in png.inc)
|
||||
PNG_HAVE_IDAT equ 0x04
|
||||
;PNG_AFTER_IDAT 0x08 (defined in png.inc)
|
||||
PNG_HAVE_IEND equ 0x10
|
||||
;0x20 (unused)
|
||||
;0x40 (unused)
|
||||
;0x80 (unused)
|
||||
PNG_HAVE_CHUNK_HEADER equ 0x100
|
||||
PNG_WROTE_tIME equ 0x200
|
||||
PNG_WROTE_INFO_BEFORE_PLTE equ 0x400
|
||||
PNG_BACKGROUND_IS_GRAY equ 0x800
|
||||
PNG_HAVE_PNG_SIGNATURE equ 0x1000
|
||||
PNG_HAVE_CHUNK_AFTER_IDAT equ 0x2000 ;Have another chunk after IDAT
|
||||
;0x4000 (unused)
|
||||
PNG_IS_READ_STRUCT equ 0x8000 ;Else is a write struct
|
||||
|
||||
; Flags for the transformations the PNG library does on the image data
|
||||
PNG_BGR equ 0x0001
|
||||
PNG_INTERLACE equ 0x0002
|
||||
PNG_PACK equ 0x0004
|
||||
PNG_SHIFT equ 0x0008
|
||||
PNG_SWAP_BYTES equ 0x0010
|
||||
PNG_INVERT_MONO equ 0x0020
|
||||
PNG_QUANTIZE equ 0x0040
|
||||
PNG_COMPOSE equ 0x0080 ;Was PNG_BACKGROUND
|
||||
PNG_BACKGROUND_EXPAND equ 0x0100
|
||||
PNG_EXPAND_16 equ 0x0200 ;Added to libpng 1.5.2
|
||||
PNG_16_TO_8 equ 0x0400 ;Becomes 'chop' in 1.5.4
|
||||
PNG_RGBA equ 0x0800
|
||||
PNG_EXPAND equ 0x1000
|
||||
PNG_GAMMA equ 0x2000
|
||||
PNG_GRAY_TO_RGB equ 0x4000
|
||||
PNG_FILLER equ 0x8000
|
||||
PNG_PACKSWAP equ 0x10000
|
||||
PNG_SWAP_ALPHA equ 0x20000
|
||||
PNG_STRIP_ALPHA equ 0x40000
|
||||
PNG_INVERT_ALPHA equ 0x80000
|
||||
PNG_USER_TRANSFORM equ 0x100000
|
||||
PNG_RGB_TO_GRAY_ERR equ 0x200000
|
||||
PNG_RGB_TO_GRAY_WARN equ 0x400000
|
||||
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_ADD_ALPHA equ 0x1000000 ;Added to libpng-1.2.7
|
||||
PNG_EXPAND_tRNS equ 0x2000000 ;Added to libpng-1.2.9
|
||||
PNG_SCALE_16_TO_8 equ 0x4000000 ;Added to libpng-1.5.4
|
||||
;0x8000000 unused
|
||||
;0x10000000 unused
|
||||
;0x20000000 unused
|
||||
;0x40000000 unused
|
||||
; Flags for png_create_struct
|
||||
PNG_STRUCT_PNG equ 0x0001
|
||||
PNG_STRUCT_INFO equ 0x0002
|
||||
|
||||
; Flags for the png_ptr->flags rather than declaring a byte for each one
|
||||
PNG_FLAG_ZLIB_CUSTOM_STRATEGY equ 0x0001
|
||||
PNG_FLAG_ZSTREAM_INITIALIZED equ 0x0002 ;Added to libpng-1.6.0
|
||||
;0x0004 unused
|
||||
PNG_FLAG_ZSTREAM_ENDED equ 0x0008 ;Added to libpng-1.6.0
|
||||
;0x0010 unused
|
||||
;0x0020 unused
|
||||
PNG_FLAG_ROW_INIT equ 0x0040
|
||||
PNG_FLAG_FILLER_AFTER equ 0x0080
|
||||
PNG_FLAG_CRC_ANCILLARY_USE equ 0x0100
|
||||
PNG_FLAG_CRC_ANCILLARY_NOWARN equ 0x0200
|
||||
PNG_FLAG_CRC_CRITICAL_USE equ 0x0400
|
||||
PNG_FLAG_CRC_CRITICAL_IGNORE equ 0x0800
|
||||
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_DETECT_UNINITIALIZED equ 0x4000 ;Added to libpng-1.5.4
|
||||
;PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000
|
||||
;PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000
|
||||
PNG_FLAG_LIBRARY_MISMATCH equ 0x20000
|
||||
PNG_FLAG_STRIP_ERROR_NUMBERS equ 0x40000
|
||||
PNG_FLAG_STRIP_ERROR_TEXT equ 0x80000
|
||||
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_ERRORS_WARN equ 0x400000 ;Added to libpng-1.6.0
|
||||
|
||||
; 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_INVERSE equ 65909
|
||||
PNG_GAMMA_sRGB_INVERSE equ 45455
|
||||
|
||||
macro PNG_ROWBYTES pixel_bits, width
|
||||
{
|
||||
local .end0
|
||||
if pixel_bits eq eax
|
||||
else
|
||||
mov eax,pixel_bits
|
||||
end if
|
||||
cmp eax,8
|
||||
jge .end0
|
||||
add eax,7
|
||||
.end0:
|
||||
shr eax,3
|
||||
imul eax,width
|
||||
}
|
||||
|
||||
; In 1.7.0 the definitions will be made public in png.inc to avoid having to
|
||||
; duplicate the same definitions in application code.
|
||||
|
||||
png_IDAT equ 'IDAT'
|
||||
png_IEND equ 'IEND'
|
||||
png_IHDR equ 'IHDR'
|
||||
png_PLTE equ 'PLTE'
|
||||
png_bKGD equ 'bKGD'
|
||||
png_cHRM equ 'cHRM'
|
||||
png_fRAc equ 'fRAc' ;registered, not defined
|
||||
png_gAMA equ 'gAMA'
|
||||
png_gIFg equ 'gIFg'
|
||||
png_gIFt equ 'gIFt' ;deprecated
|
||||
png_gIFx equ 'gIFx'
|
||||
png_hIST equ 'hIST'
|
||||
png_iCCP equ 'iCCP'
|
||||
png_iTXt equ 'iTXt'
|
||||
png_oFFs equ 'oFFs'
|
||||
png_pCAL equ 'pCAL'
|
||||
png_pHYs equ 'pHYs'
|
||||
png_sBIT equ 'sBIT'
|
||||
png_sCAL equ 'sCAL'
|
||||
png_sPLT equ 'sPLT'
|
||||
png_sRGB equ 'sRGB'
|
||||
png_sTER equ 'sTER'
|
||||
png_tEXt equ 'tEXt'
|
||||
png_tIME equ 'tIME'
|
||||
png_tRNS equ 'tRNS'
|
||||
png_zTXt equ 'zTXt'
|
||||
|
||||
;Test on flag values as defined in the spec (section 5.4):
|
||||
macro PNG_CHUNK_ANCILLARY c
|
||||
{
|
||||
mov eax,c
|
||||
shr eax,29
|
||||
and eax,1
|
||||
}
|
||||
macro PNG_CHUNK_CRITICAL c
|
||||
{
|
||||
PNG_CHUNK_ANCILLARY c
|
||||
xor eax,1
|
||||
}
|
||||
macro PNG_CHUNK_PRIVATE c
|
||||
{
|
||||
mov eax,c
|
||||
shr eax,21
|
||||
and eax,1
|
||||
}
|
||||
macro PNG_CHUNK_RESERVED c
|
||||
{
|
||||
mov eax,c
|
||||
shr eax,13
|
||||
and eax,1
|
||||
}
|
||||
macro PNG_CHUNK_SAFE_TO_COPY c
|
||||
{
|
||||
mov eax,c
|
||||
shr eax,5
|
||||
and eax,1
|
||||
}
|
||||
|
||||
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_MASK equ (PNG_FLAG_CRC_ANCILLARY_MASK or PNG_FLAG_CRC_CRITICAL_MASK)
|
||||
|
||||
macro PNG_sRGB_FROM_LINEAR linear
|
||||
{
|
||||
mov eax,linear
|
||||
shr eax,15
|
||||
shl eax,1
|
||||
add eax,png_sRGB_base
|
||||
movzx eax,word[eax]
|
||||
push ebx ecx
|
||||
mov ebx,linear
|
||||
shr ebx,15
|
||||
add ebx,png_sRGB_delta
|
||||
mov ecx,linear
|
||||
and ecx,0x7fff
|
||||
imul ecx,ebx
|
||||
shr ecx,12
|
||||
add eax,ecx
|
||||
pop ecx ebx
|
||||
shr eax,8
|
||||
;;;and eax,0xff
|
||||
}
|
||||
; 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
|
||||
; 16-bit value; it has been multiplied by 255!
|
||||
|
||||
PNG_UNEXPECTED_ZLIB_RETURN equ (-7)
|
||||
|
||||
;...
|
||||
|
||||
; Suggested size for a number buffer (enough for 64 bits and a sign!)
|
||||
PNG_NUMBER_BUFFER_SIZE equ 24
|
||||
|
||||
; These are the integer formats currently supported, the name is formed from
|
||||
; the standard printf(3) format string.
|
||||
|
||||
PNG_NUMBER_FORMAT_u equ 1 ;chose unsigned API!
|
||||
PNG_NUMBER_FORMAT_02u equ 2
|
||||
PNG_NUMBER_FORMAT_d equ 1 ;chose signed API!
|
||||
PNG_NUMBER_FORMAT_02d equ 2
|
||||
PNG_NUMBER_FORMAT_x equ 3
|
||||
PNG_NUMBER_FORMAT_02x equ 4
|
||||
PNG_NUMBER_FORMAT_fixed equ 5 ;choose the signed API
|
||||
|
||||
; New defines and members adding in libpng-1.5.4
|
||||
PNG_WARNING_PARAMETER_SIZE equ 32
|
||||
PNG_WARNING_PARAMETER_COUNT equ 8 ;Maximum 9; see pngerror.asm
|
||||
|
||||
PNG_CHUNK_WARNING equ 0 ;never an error
|
||||
PNG_CHUNK_WRITE_ERROR equ 1 ;an error only on write
|
||||
PNG_CHUNK_ERROR equ 2 ;always an error
|
||||
|
||||
; ASCII to FP interfaces, currently only implemented if sCAL
|
||||
; support is required.
|
||||
|
||||
; MAX_DIGITS is actually the maximum number of characters in an sCAL
|
||||
; width or height, derived from the precision (number of significant
|
||||
; digits - a build time settable option) and assumptions about the
|
||||
; maximum ridiculous 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.
|
||||
; 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.
|
||||
|
||||
; The format of a number is defined in the PNG extensions specification
|
||||
; and this API is strictly conformant to that spec, not anyone elses!
|
||||
|
||||
; The format as a regular expression is:
|
||||
|
||||
; [+-]?[0-9]+.?([Ee][+-]?[0-9]+)?
|
||||
|
||||
; or:
|
||||
|
||||
; [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)?
|
||||
|
||||
; 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.
|
||||
|
||||
; NOTE: The dangling E problem.
|
||||
; There is a PNG valid floating point number in the following:
|
||||
|
||||
; PNG floating point numbers are not greedy.
|
||||
|
||||
; Working this out requires *TWO* character lookahead (because of the
|
||||
; 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
|
||||
; if the value were ever to be embedded in something more complex. Use
|
||||
; ANSI-C strtod if you need the lookahead.
|
||||
|
||||
; State table for the parser.
|
||||
PNG_FP_INTEGER equ 0 ;before or in integer
|
||||
PNG_FP_FRACTION equ 1 ;before or in fraction
|
||||
PNG_FP_EXPONENT equ 2 ;before or in exponent
|
||||
PNG_FP_STATE equ 3 ;mask for the above
|
||||
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_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_ANY equ 60 ;Saw any of the above 4
|
||||
|
||||
; 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_NEGATIVE equ 128 ;A negative number, including "-0"
|
||||
PNG_FP_NONZERO equ 256 ;A non-zero value
|
||||
PNG_FP_STICKY equ 448 ;The above three flags
|
||||
|
||||
; 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.)
|
||||
|
||||
PNG_FP_INVALID equ 512 ;Available for callers as a distinct value
|
||||
|
||||
; Result codes for the parser (boolean - true meants ok, false means
|
||||
; not ok yet.)
|
||||
|
||||
PNG_FP_MAYBE equ 0 ;The number may be valid in the future
|
||||
PNG_FP_OK equ 1 ;The number is valid
|
||||
|
||||
; The internal structure that png_image::opaque points to.
|
||||
struct png_control
|
||||
png_ptr dd ? ;png_structp
|
||||
info_ptr dd ? ;png_infop
|
||||
error_buf dd ? ;voidp ;Always a jmp_buf at present.
|
||||
|
||||
memory dd ? ;bytep ;Memory buffer.
|
||||
size dd ? ;png_size_t ;Size of the memory buffer.
|
||||
|
||||
for_write dd ? ;uint ;:1;Otherwise it is a read structure
|
||||
owned_file dd ? ;uint ;:1;We own the file in io_ptr
|
||||
ends
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,453 +1,453 @@
|
||||
|
||||
; pngstruct.inc - header file for PNG reference library
|
||||
|
||||
; Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
; Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
||||
; This code is released under the libpng license.
|
||||
; For conditions of distribution and use, see the disclaimer
|
||||
; and license in png.inc
|
||||
|
||||
|
||||
; 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
|
||||
; people who will be modifying the library for their own special needs.
|
||||
; It should NOT be accessed directly by an application.
|
||||
|
||||
|
||||
; zlib.inc defines the structure z_stream, an instance of which is included
|
||||
; in this structure and is required for decompressing the LZ compressed
|
||||
; data in PNG files.
|
||||
|
||||
include '../../../../../../fs/kfar/trunk/zlib/zlib.inc'
|
||||
|
||||
; 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
|
||||
; 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
|
||||
; (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)
|
||||
; and may even improve performance on some systems (and degrade it on others.)
|
||||
|
||||
|
||||
ZLIB_IO_MAX equ 0xffff ;-1 ;uInt
|
||||
|
||||
|
||||
; The type of a compression buffer list used by the write code.
|
||||
struct png_compression_buffer
|
||||
next dd ? ;struct png_compression_buffer *
|
||||
output db ? ;byte[1] ;actually zbuf_size
|
||||
ends
|
||||
|
||||
macro PNG_COMPRESSION_BUFFER_SIZE pp
|
||||
{
|
||||
mov eax,png_compression_buffer.output
|
||||
add eax,[pp+png_struct.zbuffer_size]
|
||||
}
|
||||
|
||||
; Colorspace support; structures used in png_struct, png_info and in internal
|
||||
; functions to hold and communicate information about the color space.
|
||||
|
||||
; PNG_COLORSPACE_SUPPORTED is only required if the application will perform
|
||||
; colorspace corrections, otherwise all the colorspace information can be
|
||||
; skipped and the size of libpng can be reduced (significantly) by compiling
|
||||
; out the colorspace support.
|
||||
|
||||
if PNG_COLORSPACE_SUPPORTED eq 1
|
||||
; 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)).
|
||||
|
||||
struct png_xy
|
||||
redx dd ? ;png_fixed_point
|
||||
redy dd ?
|
||||
greenx dd ?
|
||||
greeny dd ?
|
||||
bluex dd ?
|
||||
bluey dd ?
|
||||
whitex dd ?
|
||||
whitey dd ?
|
||||
ends
|
||||
|
||||
; 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
|
||||
|
||||
struct png_XYZ
|
||||
red_X dd ? ;png_fixed_point
|
||||
red_Y dd ?
|
||||
red_Z dd ?
|
||||
green_X dd ?
|
||||
green_Y dd ?
|
||||
green_Z dd ?
|
||||
blue_X dd ?
|
||||
blue_Y dd ?
|
||||
blue_Z dd ?
|
||||
ends
|
||||
end if ;COLORSPACE
|
||||
|
||||
if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
|
||||
; A colorspace is all the above plus, potentially, profile information;
|
||||
; 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
|
||||
; is retained here and is checked.
|
||||
|
||||
; 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
|
||||
; application.
|
||||
|
||||
struct png_colorspace
|
||||
if PNG_GAMMA_SUPPORTED eq 1
|
||||
gamma dd ? ;png_fixed_point ;File gamma
|
||||
end if
|
||||
|
||||
if PNG_COLORSPACE_SUPPORTED eq 1
|
||||
end_points_xy png_xy ;End points as chromaticities
|
||||
end_points_XYZ png_XYZ ;End points as CIE XYZ colorant values
|
||||
rendering_intent dw ? ;uint_16 ;Rendering intent of a profile
|
||||
end if
|
||||
|
||||
; Flags are always defined to simplify the code.
|
||||
flags dw ? ;uint_16 ;As defined below
|
||||
ends
|
||||
|
||||
; General flags for the 'flags' field
|
||||
PNG_COLORSPACE_HAVE_GAMMA equ 0x0001
|
||||
PNG_COLORSPACE_HAVE_ENDPOINTS equ 0x0002
|
||||
PNG_COLORSPACE_HAVE_INTENT equ 0x0004
|
||||
PNG_COLORSPACE_FROM_gAMA equ 0x0008
|
||||
PNG_COLORSPACE_FROM_cHRM equ 0x0010
|
||||
PNG_COLORSPACE_FROM_sRGB equ 0x0020
|
||||
PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB equ 0x0040
|
||||
PNG_COLORSPACE_MATCHES_sRGB equ 0x0080 ;exact match on profile
|
||||
PNG_COLORSPACE_INVALID equ 0x8000
|
||||
macro PNG_COLORSPACE_CANCEL flags {(0xffff xor (flags))}
|
||||
end if ;COLORSPACE || GAMMA
|
||||
|
||||
struct png_struct
|
||||
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
|
||||
longjmp_fn dd ? ;png_longjmp_ptr ;setjmp non-local goto function.
|
||||
jmp_buf_ptr dd ? ;jmp_buf * ;passed to longjmp_fn
|
||||
jmp_buf_size dd ? ;size_t ;size of the above, if allocated
|
||||
end if
|
||||
error_fn dd ? ;png_error_ptr ;function for printing errors and aborting
|
||||
if PNG_WARNINGS_SUPPORTED eq 1
|
||||
warning_fn dd ? ;png_error_ptr ;function for printing warnings
|
||||
end if
|
||||
error_ptr dd ? ;voidp ;user supplied struct for error functions
|
||||
write_data_fn dd ? ;png_rw_ptr ;function for writing output 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
|
||||
|
||||
if PNG_READ_USER_TRANSFORM_SUPPORTED eq 1
|
||||
read_user_transform_fn dd ? ;png_user_transform_ptr ;user read transform
|
||||
end if
|
||||
|
||||
if PNG_WRITE_USER_TRANSFORM_SUPPORTED eq 1
|
||||
write_user_transform_fn dd ? ;png_user_transform_ptr ; user write transform
|
||||
end if
|
||||
|
||||
; These were added in libpng-1.0.2
|
||||
if PNG_USER_TRANSFORM_PTR_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_depth db ? ;byte ;bit depth of user transformed pixels
|
||||
user_transform_channels db ? ;byte ;channels in user transformed pixels
|
||||
rb 2 ;align
|
||||
end if
|
||||
end if
|
||||
|
||||
mode dd ? ;uint_32 ;tells us where we are in the PNG file
|
||||
flags dd ? ;uint_32 ;flags indicating various things to libpng
|
||||
transformations dd ? ;uint_32 ;which transformations to perform
|
||||
|
||||
zowner dd ? ;uint_32 ;ID (chunk type) of zstream owner, 0 if none
|
||||
zstream z_stream ;decompression structure
|
||||
|
||||
zbuffer_list dd ? ;png_compression_bufferp ;Created on demand during write
|
||||
zbuffer_size dd ? ;uInt ;size of the actual buffer
|
||||
|
||||
zlib_level dd ? ;int ;holds zlib compression level
|
||||
zlib_method dd ? ;int ;holds zlib compression method
|
||||
zlib_window_bits dd ? ;int ;holds zlib compression window bits
|
||||
zlib_mem_level dd ? ;int ;holds zlib compression memory level
|
||||
zlib_strategy dd ? ;int ;holds zlib compression strategy
|
||||
; Added at libpng 1.5.4
|
||||
if PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED eq 1
|
||||
zlib_text_level dd ? ;int ;holds zlib compression level
|
||||
zlib_text_method dd ? ;int ;holds zlib compression method
|
||||
zlib_text_window_bits dd ? ;int ;holds zlib compression window bits
|
||||
zlib_text_mem_level dd ? ;int ;holds zlib compression memory level
|
||||
zlib_text_strategy dd ? ;int ;holds zlib compression strategy
|
||||
end if
|
||||
;End of material added at libpng 1.5.4
|
||||
;Added at libpng 1.6.0
|
||||
zlib_set_level dd ? ;int ;Actual values set into the zstream on write
|
||||
zlib_set_method dd ? ;int
|
||||
zlib_set_window_bits dd ? ;int
|
||||
zlib_set_mem_level dd ? ;int
|
||||
zlib_set_strategy dd ? ;int
|
||||
|
||||
width dd ? ;uint_32 ;width of image in pixels
|
||||
height dd ? ;uint_32 ;height of image in pixels
|
||||
num_rows dd ? ;uint_32 ;number of rows in current pass
|
||||
usr_width dd ? ;uint_32 ;width of row at start of write
|
||||
rowbytes dd ? ;png_size_t ;size of row in bytes
|
||||
iwidth dd ? ;uint_32 ;width of current interlaced row in pixels
|
||||
row_number dd ? ;uint_32 ;current row in interlace pass
|
||||
chunk_name dd ? ;uint_32 ;PNG_CHUNK() id of current chunk
|
||||
prev_row dd ? ;bytep ;buffer to save previous (unfiltered) row.
|
||||
;While reading this is a pointer into
|
||||
;big_prev_row; while writing it is separately
|
||||
;allocated if needed.
|
||||
|
||||
row_buf dd ? ;bytep ;buffer to save current (unfiltered) row.
|
||||
;While reading, this is a pointer into
|
||||
;big_row_buf; while writing it is separately
|
||||
;allocated.
|
||||
|
||||
if PNG_WRITE_FILTER_SUPPORTED eq 1
|
||||
try_row dd ? ;bytep ;buffer to save trial row when filtering
|
||||
tst_row dd ? ;bytep ;buffer to save best trial row when filtering
|
||||
end if
|
||||
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
|
||||
crc dd ? ;uint_32 ;current chunk CRC value
|
||||
palette dd ? ;png_colorp ;palette from the input file
|
||||
num_palette dw ? ;uint_16 ;number of color entries in palette
|
||||
rb 2 ;align
|
||||
; Added at libpng-1.5.10
|
||||
if PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED eq 1
|
||||
num_palette_max dd ? ;int ;maximum palette index found in IDAT
|
||||
end if
|
||||
|
||||
num_trans dw ? ;uint_16 ;number of transparency values
|
||||
compression db ? ;byte ;file compression type (always 0)
|
||||
filter db ? ;byte ;file filter type (always 0)
|
||||
interlaced db ? ;byte ;PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7
|
||||
pass db ? ;byte ;current interlace pass (0 - 6)
|
||||
do_filter db ? ;byte ;row filter flags (see PNG_FILTER_ in png.inc)
|
||||
color_type db ? ;byte ;color type of file
|
||||
bit_depth db ? ;byte ;bit depth of file
|
||||
usr_bit_depth db ? ;byte ;bit depth of users row: write only
|
||||
pixel_depth db ? ;byte ;number of bits per pixel
|
||||
channels db ? ;byte ;number of channels in file
|
||||
usr_channels db ? ;byte ;channels at start of write: write only
|
||||
sig_bytes db ? ;byte ;magic bytes read/written from start of file
|
||||
maximum_pixel_depth db ? ;byte ;pixel depth used for the row buffers
|
||||
transformed_pixel_depth db ? ;byte ;pixel depth after read/write transforms
|
||||
;if PNG_ZLIB_VERNUM >= 0x1240
|
||||
;zstream_start db 1 ;byte ;at start of an input zlib stream
|
||||
;end if ;Zlib >= 1.2.4
|
||||
if (PNG_READ_FILLER_SUPPORTED eq 1) | (PNG_WRITE_FILLER_SUPPORTED eq 1)
|
||||
filler dw ? ;uint_16 ;filler bytes for pixel expansion
|
||||
end if
|
||||
|
||||
if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \
|
||||
(PNG_READ_ALPHA_MODE_SUPPORTED eq 1)
|
||||
background_gamma_type db ? ;byte
|
||||
rb 1 ;align
|
||||
background_gamma dd ? ;png_fixed_point
|
||||
background png_color_16 ;background color in screen gamma space
|
||||
rb 1 ;align
|
||||
if PNG_READ_GAMMA_SUPPORTED eq 1
|
||||
background_1 png_color_16 ;background normalized to gamma 1.0
|
||||
rb 1 ;align
|
||||
end if
|
||||
end if ;bKGD
|
||||
|
||||
if PNG_WRITE_FLUSH_SUPPORTED eq 1
|
||||
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_rows dd ? ;uint_32 ;number of rows written since last flush
|
||||
end if
|
||||
|
||||
if PNG_READ_GAMMA_SUPPORTED eq 1
|
||||
gamma_shift dd ? ;int ;number of "insignificant" bits in 16-bit gamma
|
||||
screen_gamma dd ? ;png_fixed_point ;screen gamma value (display_exponent)
|
||||
|
||||
gamma_table dd ? ;bytep ;gamma table for 8-bit depth files
|
||||
gamma_16_table dd ? ;uint_16pp ;gamma table for 16-bit depth files
|
||||
if (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \
|
||||
(PNG_READ_ALPHA_MODE_SUPPORTED eq 1) | \
|
||||
(PNG_READ_RGB_TO_GRAY_SUPPORTED eq 1)
|
||||
gamma_from_1 dd ? ;bytep ;converts from 1.0 to screen
|
||||
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_to_1 dd ? ;uint_16pp ;converts from file to 1.0
|
||||
end if ;READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY
|
||||
end if
|
||||
|
||||
if (PNG_READ_GAMMA_SUPPORTED eq 1) | (PNG_sBIT_SUPPORTED eq 1)
|
||||
sig_bit png_color_8 ;significant bits in each available channel
|
||||
end if
|
||||
|
||||
if (PNG_READ_SHIFT_SUPPORTED eq 1) | (PNG_WRITE_SHIFT_SUPPORTED eq 1)
|
||||
shift png_color_8 ;shift for significant bit tranformation
|
||||
rb 2 ;align
|
||||
end if
|
||||
|
||||
if (PNG_tRNS_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_color png_color_16 ;transparent color for non-paletted files
|
||||
rb 3 ;align
|
||||
end if
|
||||
|
||||
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
|
||||
if PNG_PROGRESSIVE_READ_SUPPORTED eq 1
|
||||
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
|
||||
end_fn dd ? ;png_progressive_end_ptr ;called after image is complete
|
||||
save_buffer_ptr dd ? ;bytep ;current location in save_buffer
|
||||
save_buffer dd ? ;bytep ;buffer for previously read data
|
||||
current_buffer_ptr dd ? ;bytep ;current location in current_buffer
|
||||
current_buffer dd ? ;bytep ;buffer for recently used data
|
||||
push_length dd ? ;uint_32 ;size of current input chunk
|
||||
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_max dd ? ;png_size_t ;total size of save_buffer
|
||||
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
|
||||
process_mode dd ? ;int ;what push library is currently doing
|
||||
cur_palette dd ? ;int ;current push library palette index
|
||||
|
||||
end if ;PROGRESSIVE_READ
|
||||
|
||||
if PNG_READ_QUANTIZE_SUPPORTED eq 1
|
||||
palette_lookup dd ? ;bytep ;lookup table for quantizing
|
||||
quantize_index dd ? ;bytep ;index translation for palette files
|
||||
end if
|
||||
|
||||
; Options
|
||||
if PNG_SET_OPTION_SUPPORTED eq 1
|
||||
options db ? ;byte ;On/off state (up to 4 options)
|
||||
end if
|
||||
|
||||
;#if PNG_LIBPNG_VER < 10700
|
||||
; To do: remove this from libpng-1.7
|
||||
if PNG_TIME_RFC1123_SUPPORTED eq 1
|
||||
time_buffer rb 29 ;char[29] ;String to hold RFC 1123 time text
|
||||
rb 2 ;align
|
||||
end if
|
||||
;end if
|
||||
|
||||
; New members added in libpng-1.0.6
|
||||
|
||||
free_me dd ? ;uint_32 ;flags items libpng is responsible for freeing
|
||||
|
||||
if PNG_USER_CHUNKS_SUPPORTED eq 1
|
||||
user_chunk_ptr dd ? ;voidp
|
||||
if PNG_READ_USER_CHUNKS_SUPPORTED eq 1
|
||||
read_user_chunk_fn dd ? ;png_user_chunk_ptr ;user read chunk handler
|
||||
end if
|
||||
end if
|
||||
|
||||
if PNG_SET_UNKNOWN_CHUNKS_SUPPORTED eq 1
|
||||
unknown_default dd ? ;int ; As PNG_HANDLE_*
|
||||
num_chunk_list dd ? ;unsigned int ; Number of entries in the list
|
||||
chunk_list dd ? ;bytep ; List of byte[5]; the textual chunk name
|
||||
; followed by a PNG_HANDLE_* byte
|
||||
end if
|
||||
|
||||
; New members added in libpng-1.0.3
|
||||
if PNG_READ_RGB_TO_GRAY_SUPPORTED eq 1
|
||||
rgb_to_gray_status db ? ;byte
|
||||
; Added in libpng 1.5.5 to record setting of coefficients:
|
||||
rgb_to_gray_coefficients_set db ? ;byte
|
||||
; These were changed from byte in libpng-1.0.6
|
||||
rgb_to_gray_red_coeff dw ? ;uint_16
|
||||
rgb_to_gray_green_coeff dw ? ;uint_16
|
||||
; deleted in 1.5.5: rgb_to_gray_blue_coeff;
|
||||
rb 2 ;align
|
||||
end if
|
||||
|
||||
if PNG_MNG_FEATURES_SUPPORTED eq 1
|
||||
; New member added in libpng-1.0.4 (renamed in 1.0.9)
|
||||
; Changed from byte to uint_32 at version 1.2.0
|
||||
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
|
||||
filter_type db ? ;byte
|
||||
rb 3 ;align
|
||||
end if
|
||||
|
||||
; 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
|
||||
if PNG_USER_MEM_SUPPORTED eq 1
|
||||
mem_ptr dd ? ;voidp ;user supplied struct for mem functions
|
||||
malloc_fn dd ? ;malloc_ptr ;function for allocating memory
|
||||
free_fn dd ? ;free_ptr ;function for freeing memory
|
||||
end if
|
||||
|
||||
; New member added in libpng-1.0.13 and 1.2.0
|
||||
big_row_buf dd ? ;bytep ;buffer to save current (unfiltered) row
|
||||
|
||||
if PNG_READ_QUANTIZE_SUPPORTED eq 1
|
||||
; The following three members were added at version 1.0.14 and 1.2.4
|
||||
quantize_sort dd ? ;bytep ;working sort array
|
||||
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
|
||||
end if
|
||||
|
||||
; New members added in libpng-1.0.16 and 1.2.6
|
||||
compression_type db ? ;byte
|
||||
rb 3 ;align
|
||||
|
||||
if PNG_USER_LIMITS_SUPPORTED eq 1
|
||||
user_width_max dd ? ;uint_32
|
||||
user_height_max dd ? ;uint_32
|
||||
|
||||
; Added in libpng-1.4.0: Total number of sPLT, text, and unknown
|
||||
; chunks that can be stored (0 means unlimited).
|
||||
|
||||
user_chunk_cache_max dd ? ;uint_32
|
||||
|
||||
; Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
|
||||
; can occupy when decompressed. 0 means unlimited.
|
||||
|
||||
user_chunk_malloc_max dd ? ;png_alloc_size_t
|
||||
end if
|
||||
|
||||
; New member added in libpng-1.0.25 and 1.2.17
|
||||
if PNG_READ_UNKNOWN_CHUNKS_SUPPORTED eq 1
|
||||
; Temporary storage for unknown chunk that the library doesn't recognize,
|
||||
; used while reading the chunk.
|
||||
|
||||
unknown_chunk png_unknown_chunk
|
||||
rb 3 ;align
|
||||
end if
|
||||
|
||||
; New member added in libpng-1.2.26
|
||||
old_big_row_buf_size dd ? ;png_size_t
|
||||
|
||||
if PNG_READ_SUPPORTED eq 1
|
||||
; New member added in libpng-1.2.30
|
||||
read_buffer dd ? ;bytep ;buffer for reading chunk data
|
||||
read_buffer_size dd ? ;png_alloc_size_t ;current size of the buffer
|
||||
end if
|
||||
if PNG_SEQUENTIAL_READ_SUPPORTED eq 1
|
||||
IDAT_read_size dd ? ;uInt ;limit on read buffer size for IDAT
|
||||
end if
|
||||
|
||||
if PNG_IO_STATE_SUPPORTED eq 1
|
||||
; New member added in libpng-1.4.0
|
||||
io_state dd ? ;uint_32
|
||||
end if
|
||||
|
||||
; New member added in libpng-1.5.6
|
||||
big_prev_row dd ? ;bytep
|
||||
|
||||
; New member added in libpng-1.5.7
|
||||
read_filter rd PNG_FILTER_VALUE_LAST-1
|
||||
|
||||
if PNG_READ_SUPPORTED eq 1
|
||||
if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
|
||||
colorspace png_colorspace
|
||||
end if
|
||||
end if
|
||||
ends
|
||||
|
||||
; pngstruct.inc - header file for PNG reference library
|
||||
|
||||
; Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
; Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
||||
; This code is released under the libpng license.
|
||||
; For conditions of distribution and use, see the disclaimer
|
||||
; and license in png.inc
|
||||
|
||||
|
||||
; 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
|
||||
; people who will be modifying the library for their own special needs.
|
||||
; It should NOT be accessed directly by an application.
|
||||
|
||||
|
||||
; zlib.inc defines the structure z_stream, an instance of which is included
|
||||
; in this structure and is required for decompressing the LZ compressed
|
||||
; data in PNG files.
|
||||
|
||||
include '../../../../../../fs/kfar/trunk/zlib/zlib.inc'
|
||||
|
||||
; 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
|
||||
; 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
|
||||
; (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)
|
||||
; and may even improve performance on some systems (and degrade it on others.)
|
||||
|
||||
|
||||
ZLIB_IO_MAX equ 0xffff ;-1 ;uInt
|
||||
|
||||
|
||||
; The type of a compression buffer list used by the write code.
|
||||
struct png_compression_buffer
|
||||
next dd ? ;struct png_compression_buffer *
|
||||
output db ? ;byte[1] ;actually zbuf_size
|
||||
ends
|
||||
|
||||
macro PNG_COMPRESSION_BUFFER_SIZE pp
|
||||
{
|
||||
mov eax,png_compression_buffer.output
|
||||
add eax,[pp+png_struct.zbuffer_size]
|
||||
}
|
||||
|
||||
; Colorspace support; structures used in png_struct, png_info and in internal
|
||||
; functions to hold and communicate information about the color space.
|
||||
|
||||
; PNG_COLORSPACE_SUPPORTED is only required if the application will perform
|
||||
; colorspace corrections, otherwise all the colorspace information can be
|
||||
; skipped and the size of libpng can be reduced (significantly) by compiling
|
||||
; out the colorspace support.
|
||||
|
||||
if PNG_COLORSPACE_SUPPORTED eq 1
|
||||
; 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)).
|
||||
|
||||
struct png_xy
|
||||
redx dd ? ;png_fixed_point
|
||||
redy dd ?
|
||||
greenx dd ?
|
||||
greeny dd ?
|
||||
bluex dd ?
|
||||
bluey dd ?
|
||||
whitex dd ?
|
||||
whitey dd ?
|
||||
ends
|
||||
|
||||
; 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
|
||||
|
||||
struct png_XYZ
|
||||
red_X dd ? ;png_fixed_point
|
||||
red_Y dd ?
|
||||
red_Z dd ?
|
||||
green_X dd ?
|
||||
green_Y dd ?
|
||||
green_Z dd ?
|
||||
blue_X dd ?
|
||||
blue_Y dd ?
|
||||
blue_Z dd ?
|
||||
ends
|
||||
end if ;COLORSPACE
|
||||
|
||||
if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
|
||||
; A colorspace is all the above plus, potentially, profile information;
|
||||
; 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
|
||||
; is retained here and is checked.
|
||||
|
||||
; 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
|
||||
; application.
|
||||
|
||||
struct png_colorspace
|
||||
if PNG_GAMMA_SUPPORTED eq 1
|
||||
gamma dd ? ;png_fixed_point ;File gamma
|
||||
end if
|
||||
|
||||
if PNG_COLORSPACE_SUPPORTED eq 1
|
||||
end_points_xy png_xy ;End points as chromaticities
|
||||
end_points_XYZ png_XYZ ;End points as CIE XYZ colorant values
|
||||
rendering_intent dw ? ;uint_16 ;Rendering intent of a profile
|
||||
end if
|
||||
|
||||
; Flags are always defined to simplify the code.
|
||||
flags dw ? ;uint_16 ;As defined below
|
||||
ends
|
||||
|
||||
; General flags for the 'flags' field
|
||||
PNG_COLORSPACE_HAVE_GAMMA equ 0x0001
|
||||
PNG_COLORSPACE_HAVE_ENDPOINTS equ 0x0002
|
||||
PNG_COLORSPACE_HAVE_INTENT equ 0x0004
|
||||
PNG_COLORSPACE_FROM_gAMA equ 0x0008
|
||||
PNG_COLORSPACE_FROM_cHRM equ 0x0010
|
||||
PNG_COLORSPACE_FROM_sRGB equ 0x0020
|
||||
PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB equ 0x0040
|
||||
PNG_COLORSPACE_MATCHES_sRGB equ 0x0080 ;exact match on profile
|
||||
PNG_COLORSPACE_INVALID equ 0x8000
|
||||
macro PNG_COLORSPACE_CANCEL flags {(0xffff xor (flags))}
|
||||
end if ;COLORSPACE || GAMMA
|
||||
|
||||
struct png_struct
|
||||
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
|
||||
longjmp_fn dd ? ;png_longjmp_ptr ;setjmp non-local goto function.
|
||||
jmp_buf_ptr dd ? ;jmp_buf * ;passed to longjmp_fn
|
||||
jmp_buf_size dd ? ;size_t ;size of the above, if allocated
|
||||
end if
|
||||
error_fn dd ? ;png_error_ptr ;function for printing errors and aborting
|
||||
if PNG_WARNINGS_SUPPORTED eq 1
|
||||
warning_fn dd ? ;png_error_ptr ;function for printing warnings
|
||||
end if
|
||||
error_ptr dd ? ;voidp ;user supplied struct for error functions
|
||||
write_data_fn dd ? ;png_rw_ptr ;function for writing output 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
|
||||
|
||||
if PNG_READ_USER_TRANSFORM_SUPPORTED eq 1
|
||||
read_user_transform_fn dd ? ;png_user_transform_ptr ;user read transform
|
||||
end if
|
||||
|
||||
if PNG_WRITE_USER_TRANSFORM_SUPPORTED eq 1
|
||||
write_user_transform_fn dd ? ;png_user_transform_ptr ; user write transform
|
||||
end if
|
||||
|
||||
; These were added in libpng-1.0.2
|
||||
if PNG_USER_TRANSFORM_PTR_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_depth db ? ;byte ;bit depth of user transformed pixels
|
||||
user_transform_channels db ? ;byte ;channels in user transformed pixels
|
||||
rb 2 ;align
|
||||
end if
|
||||
end if
|
||||
|
||||
mode dd ? ;uint_32 ;tells us where we are in the PNG file
|
||||
flags dd ? ;uint_32 ;flags indicating various things to libpng
|
||||
transformations dd ? ;uint_32 ;which transformations to perform
|
||||
|
||||
zowner dd ? ;uint_32 ;ID (chunk type) of zstream owner, 0 if none
|
||||
zstream z_stream ;decompression structure
|
||||
|
||||
zbuffer_list dd ? ;png_compression_bufferp ;Created on demand during write
|
||||
zbuffer_size dd ? ;uInt ;size of the actual buffer
|
||||
|
||||
zlib_level dd ? ;int ;holds zlib compression level
|
||||
zlib_method dd ? ;int ;holds zlib compression method
|
||||
zlib_window_bits dd ? ;int ;holds zlib compression window bits
|
||||
zlib_mem_level dd ? ;int ;holds zlib compression memory level
|
||||
zlib_strategy dd ? ;int ;holds zlib compression strategy
|
||||
; Added at libpng 1.5.4
|
||||
if PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED eq 1
|
||||
zlib_text_level dd ? ;int ;holds zlib compression level
|
||||
zlib_text_method dd ? ;int ;holds zlib compression method
|
||||
zlib_text_window_bits dd ? ;int ;holds zlib compression window bits
|
||||
zlib_text_mem_level dd ? ;int ;holds zlib compression memory level
|
||||
zlib_text_strategy dd ? ;int ;holds zlib compression strategy
|
||||
end if
|
||||
;End of material added at libpng 1.5.4
|
||||
;Added at libpng 1.6.0
|
||||
zlib_set_level dd ? ;int ;Actual values set into the zstream on write
|
||||
zlib_set_method dd ? ;int
|
||||
zlib_set_window_bits dd ? ;int
|
||||
zlib_set_mem_level dd ? ;int
|
||||
zlib_set_strategy dd ? ;int
|
||||
|
||||
width dd ? ;uint_32 ;width of image in pixels
|
||||
height dd ? ;uint_32 ;height of image in pixels
|
||||
num_rows dd ? ;uint_32 ;number of rows in current pass
|
||||
usr_width dd ? ;uint_32 ;width of row at start of write
|
||||
rowbytes dd ? ;png_size_t ;size of row in bytes
|
||||
iwidth dd ? ;uint_32 ;width of current interlaced row in pixels
|
||||
row_number dd ? ;uint_32 ;current row in interlace pass
|
||||
chunk_name dd ? ;uint_32 ;PNG_CHUNK() id of current chunk
|
||||
prev_row dd ? ;bytep ;buffer to save previous (unfiltered) row.
|
||||
;While reading this is a pointer into
|
||||
;big_prev_row; while writing it is separately
|
||||
;allocated if needed.
|
||||
|
||||
row_buf dd ? ;bytep ;buffer to save current (unfiltered) row.
|
||||
;While reading, this is a pointer into
|
||||
;big_row_buf; while writing it is separately
|
||||
;allocated.
|
||||
|
||||
if PNG_WRITE_FILTER_SUPPORTED eq 1
|
||||
try_row dd ? ;bytep ;buffer to save trial row when filtering
|
||||
tst_row dd ? ;bytep ;buffer to save best trial row when filtering
|
||||
end if
|
||||
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
|
||||
crc dd ? ;uint_32 ;current chunk CRC value
|
||||
palette dd ? ;png_colorp ;palette from the input file
|
||||
num_palette dw ? ;uint_16 ;number of color entries in palette
|
||||
rb 2 ;align
|
||||
; Added at libpng-1.5.10
|
||||
if PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED eq 1
|
||||
num_palette_max dd ? ;int ;maximum palette index found in IDAT
|
||||
end if
|
||||
|
||||
num_trans dw ? ;uint_16 ;number of transparency values
|
||||
compression db ? ;byte ;file compression type (always 0)
|
||||
filter db ? ;byte ;file filter type (always 0)
|
||||
interlaced db ? ;byte ;PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7
|
||||
pass db ? ;byte ;current interlace pass (0 - 6)
|
||||
do_filter db ? ;byte ;row filter flags (see PNG_FILTER_ in png.inc)
|
||||
color_type db ? ;byte ;color type of file
|
||||
bit_depth db ? ;byte ;bit depth of file
|
||||
usr_bit_depth db ? ;byte ;bit depth of users row: write only
|
||||
pixel_depth db ? ;byte ;number of bits per pixel
|
||||
channels db ? ;byte ;number of channels in file
|
||||
usr_channels db ? ;byte ;channels at start of write: write only
|
||||
sig_bytes db ? ;byte ;magic bytes read/written from start of file
|
||||
maximum_pixel_depth db ? ;byte ;pixel depth used for the row buffers
|
||||
transformed_pixel_depth db ? ;byte ;pixel depth after read/write transforms
|
||||
;if PNG_ZLIB_VERNUM >= 0x1240
|
||||
;zstream_start db 1 ;byte ;at start of an input zlib stream
|
||||
;end if ;Zlib >= 1.2.4
|
||||
if (PNG_READ_FILLER_SUPPORTED eq 1) | (PNG_WRITE_FILLER_SUPPORTED eq 1)
|
||||
filler dw ? ;uint_16 ;filler bytes for pixel expansion
|
||||
end if
|
||||
|
||||
if (PNG_bKGD_SUPPORTED eq 1) | (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \
|
||||
(PNG_READ_ALPHA_MODE_SUPPORTED eq 1)
|
||||
background_gamma_type db ? ;byte
|
||||
rb 1 ;align
|
||||
background_gamma dd ? ;png_fixed_point
|
||||
background png_color_16 ;background color in screen gamma space
|
||||
rb 1 ;align
|
||||
if PNG_READ_GAMMA_SUPPORTED eq 1
|
||||
background_1 png_color_16 ;background normalized to gamma 1.0
|
||||
rb 1 ;align
|
||||
end if
|
||||
end if ;bKGD
|
||||
|
||||
if PNG_WRITE_FLUSH_SUPPORTED eq 1
|
||||
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_rows dd ? ;uint_32 ;number of rows written since last flush
|
||||
end if
|
||||
|
||||
if PNG_READ_GAMMA_SUPPORTED eq 1
|
||||
gamma_shift dd ? ;int ;number of "insignificant" bits in 16-bit gamma
|
||||
screen_gamma dd ? ;png_fixed_point ;screen gamma value (display_exponent)
|
||||
|
||||
gamma_table dd ? ;bytep ;gamma table for 8-bit depth files
|
||||
gamma_16_table dd ? ;uint_16pp ;gamma table for 16-bit depth files
|
||||
if (PNG_READ_BACKGROUND_SUPPORTED eq 1) | \
|
||||
(PNG_READ_ALPHA_MODE_SUPPORTED eq 1) | \
|
||||
(PNG_READ_RGB_TO_GRAY_SUPPORTED eq 1)
|
||||
gamma_from_1 dd ? ;bytep ;converts from 1.0 to screen
|
||||
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_to_1 dd ? ;uint_16pp ;converts from file to 1.0
|
||||
end if ;READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY
|
||||
end if
|
||||
|
||||
if (PNG_READ_GAMMA_SUPPORTED eq 1) | (PNG_sBIT_SUPPORTED eq 1)
|
||||
sig_bit png_color_8 ;significant bits in each available channel
|
||||
end if
|
||||
|
||||
if (PNG_READ_SHIFT_SUPPORTED eq 1) | (PNG_WRITE_SHIFT_SUPPORTED eq 1)
|
||||
shift png_color_8 ;shift for significant bit tranformation
|
||||
rb 2 ;align
|
||||
end if
|
||||
|
||||
if (PNG_tRNS_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_color png_color_16 ;transparent color for non-paletted files
|
||||
rb 3 ;align
|
||||
end if
|
||||
|
||||
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
|
||||
if PNG_PROGRESSIVE_READ_SUPPORTED eq 1
|
||||
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
|
||||
end_fn dd ? ;png_progressive_end_ptr ;called after image is complete
|
||||
save_buffer_ptr dd ? ;bytep ;current location in save_buffer
|
||||
save_buffer dd ? ;bytep ;buffer for previously read data
|
||||
current_buffer_ptr dd ? ;bytep ;current location in current_buffer
|
||||
current_buffer dd ? ;bytep ;buffer for recently used data
|
||||
push_length dd ? ;uint_32 ;size of current input chunk
|
||||
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_max dd ? ;png_size_t ;total size of save_buffer
|
||||
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
|
||||
process_mode dd ? ;int ;what push library is currently doing
|
||||
cur_palette dd ? ;int ;current push library palette index
|
||||
|
||||
end if ;PROGRESSIVE_READ
|
||||
|
||||
if PNG_READ_QUANTIZE_SUPPORTED eq 1
|
||||
palette_lookup dd ? ;bytep ;lookup table for quantizing
|
||||
quantize_index dd ? ;bytep ;index translation for palette files
|
||||
end if
|
||||
|
||||
; Options
|
||||
if PNG_SET_OPTION_SUPPORTED eq 1
|
||||
options db ? ;byte ;On/off state (up to 4 options)
|
||||
end if
|
||||
|
||||
;#if PNG_LIBPNG_VER < 10700
|
||||
; To do: remove this from libpng-1.7
|
||||
if PNG_TIME_RFC1123_SUPPORTED eq 1
|
||||
time_buffer rb 29 ;char[29] ;String to hold RFC 1123 time text
|
||||
rb 2 ;align
|
||||
end if
|
||||
;end if
|
||||
|
||||
; New members added in libpng-1.0.6
|
||||
|
||||
free_me dd ? ;uint_32 ;flags items libpng is responsible for freeing
|
||||
|
||||
if PNG_USER_CHUNKS_SUPPORTED eq 1
|
||||
user_chunk_ptr dd ? ;voidp
|
||||
if PNG_READ_USER_CHUNKS_SUPPORTED eq 1
|
||||
read_user_chunk_fn dd ? ;png_user_chunk_ptr ;user read chunk handler
|
||||
end if
|
||||
end if
|
||||
|
||||
if PNG_SET_UNKNOWN_CHUNKS_SUPPORTED eq 1
|
||||
unknown_default dd ? ;int ; As PNG_HANDLE_*
|
||||
num_chunk_list dd ? ;unsigned int ; Number of entries in the list
|
||||
chunk_list dd ? ;bytep ; List of byte[5]; the textual chunk name
|
||||
; followed by a PNG_HANDLE_* byte
|
||||
end if
|
||||
|
||||
; New members added in libpng-1.0.3
|
||||
if PNG_READ_RGB_TO_GRAY_SUPPORTED eq 1
|
||||
rgb_to_gray_status db ? ;byte
|
||||
; Added in libpng 1.5.5 to record setting of coefficients:
|
||||
rgb_to_gray_coefficients_set db ? ;byte
|
||||
; These were changed from byte in libpng-1.0.6
|
||||
rgb_to_gray_red_coeff dw ? ;uint_16
|
||||
rgb_to_gray_green_coeff dw ? ;uint_16
|
||||
; deleted in 1.5.5: rgb_to_gray_blue_coeff;
|
||||
rb 2 ;align
|
||||
end if
|
||||
|
||||
if PNG_MNG_FEATURES_SUPPORTED eq 1
|
||||
; New member added in libpng-1.0.4 (renamed in 1.0.9)
|
||||
; Changed from byte to uint_32 at version 1.2.0
|
||||
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
|
||||
filter_type db ? ;byte
|
||||
rb 3 ;align
|
||||
end if
|
||||
|
||||
; 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
|
||||
if PNG_USER_MEM_SUPPORTED eq 1
|
||||
mem_ptr dd ? ;voidp ;user supplied struct for mem functions
|
||||
malloc_fn dd ? ;malloc_ptr ;function for allocating memory
|
||||
free_fn dd ? ;free_ptr ;function for freeing memory
|
||||
end if
|
||||
|
||||
; New member added in libpng-1.0.13 and 1.2.0
|
||||
big_row_buf dd ? ;bytep ;buffer to save current (unfiltered) row
|
||||
|
||||
if PNG_READ_QUANTIZE_SUPPORTED eq 1
|
||||
; The following three members were added at version 1.0.14 and 1.2.4
|
||||
quantize_sort dd ? ;bytep ;working sort array
|
||||
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
|
||||
end if
|
||||
|
||||
; New members added in libpng-1.0.16 and 1.2.6
|
||||
compression_type db ? ;byte
|
||||
rb 3 ;align
|
||||
|
||||
if PNG_USER_LIMITS_SUPPORTED eq 1
|
||||
user_width_max dd ? ;uint_32
|
||||
user_height_max dd ? ;uint_32
|
||||
|
||||
; Added in libpng-1.4.0: Total number of sPLT, text, and unknown
|
||||
; chunks that can be stored (0 means unlimited).
|
||||
|
||||
user_chunk_cache_max dd ? ;uint_32
|
||||
|
||||
; Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
|
||||
; can occupy when decompressed. 0 means unlimited.
|
||||
|
||||
user_chunk_malloc_max dd ? ;png_alloc_size_t
|
||||
end if
|
||||
|
||||
; New member added in libpng-1.0.25 and 1.2.17
|
||||
if PNG_READ_UNKNOWN_CHUNKS_SUPPORTED eq 1
|
||||
; Temporary storage for unknown chunk that the library doesn't recognize,
|
||||
; used while reading the chunk.
|
||||
|
||||
unknown_chunk png_unknown_chunk
|
||||
rb 3 ;align
|
||||
end if
|
||||
|
||||
; New member added in libpng-1.2.26
|
||||
old_big_row_buf_size dd ? ;png_size_t
|
||||
|
||||
if PNG_READ_SUPPORTED eq 1
|
||||
; New member added in libpng-1.2.30
|
||||
read_buffer dd ? ;bytep ;buffer for reading chunk data
|
||||
read_buffer_size dd ? ;png_alloc_size_t ;current size of the buffer
|
||||
end if
|
||||
if PNG_SEQUENTIAL_READ_SUPPORTED eq 1
|
||||
IDAT_read_size dd ? ;uInt ;limit on read buffer size for IDAT
|
||||
end if
|
||||
|
||||
if PNG_IO_STATE_SUPPORTED eq 1
|
||||
; New member added in libpng-1.4.0
|
||||
io_state dd ? ;uint_32
|
||||
end if
|
||||
|
||||
; New member added in libpng-1.5.6
|
||||
big_prev_row dd ? ;bytep
|
||||
|
||||
; New member added in libpng-1.5.7
|
||||
read_filter rd PNG_FILTER_VALUE_LAST-1
|
||||
|
||||
if PNG_READ_SUPPORTED eq 1
|
||||
if (PNG_COLORSPACE_SUPPORTED eq 1) | (PNG_GAMMA_SUPPORTED eq 1)
|
||||
colorspace png_colorspace
|
||||
end if
|
||||
end if
|
||||
ends
|
||||
|
@ -1,299 +1,299 @@
|
||||
|
||||
txt_zv db '*',0
|
||||
txt_sp db ' ',0
|
||||
txt_buf db '1234',0
|
||||
rd 1
|
||||
|
||||
buf_param rb 80
|
||||
|
||||
macro cStr dest,txt
|
||||
{
|
||||
local .end_t
|
||||
local .m_txt
|
||||
jmp .end_t
|
||||
align 4
|
||||
.m_txt db txt,0
|
||||
align 4
|
||||
.end_t:
|
||||
if dest eq
|
||||
mov eax,.m_txt
|
||||
else
|
||||
mov dest,.m_txt
|
||||
end if
|
||||
}
|
||||
|
||||
align 4
|
||||
proc f_png_warning, h:dword, m_txt:dword
|
||||
stdcall hex_in_str,txt_buf,[h],5
|
||||
mov byte[txt_buf+5],0
|
||||
stdcall dbg_print,txt_buf,[m_txt]
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc f_png_error, h:dword, m_txt:dword
|
||||
stdcall hex_in_str,txt_buf,[h],5
|
||||
mov byte[txt_buf+5],0
|
||||
stdcall dbg_print,txt_buf,[m_txt]
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc f_png_debug, n:dword, m_txt:dword
|
||||
stdcall dbg_print,txt_sp,[m_txt]
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc dbg_print, fun:dword, mes:dword
|
||||
pushad
|
||||
mov eax,SF_BOARD
|
||||
mov ebx,SSF_DEBUG_WRITE
|
||||
|
||||
mov esi,[fun]
|
||||
cmp esi,0
|
||||
je .end0
|
||||
@@:
|
||||
mov cl,byte[esi]
|
||||
int 0x40
|
||||
inc esi
|
||||
cmp byte[esi],0
|
||||
jne @b
|
||||
mov cl,':'
|
||||
int 0x40
|
||||
mov cl,' '
|
||||
int 0x40
|
||||
.end0:
|
||||
mov esi,[mes]
|
||||
cmp esi,0
|
||||
je .end_f
|
||||
@@:
|
||||
mov cl,byte[esi]
|
||||
cmp cl,0
|
||||
je .end_f
|
||||
int 0x40
|
||||
inc esi
|
||||
jmp @b
|
||||
.end_f:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
;input:
|
||||
; zif - 1...8
|
||||
align 4
|
||||
proc hex_in_str, buf:dword,val:dword,zif:dword
|
||||
pushad
|
||||
mov edi,dword[buf]
|
||||
mov ecx,dword[zif]
|
||||
add edi,ecx
|
||||
dec edi
|
||||
mov ebx,dword[val]
|
||||
|
||||
.cycle:
|
||||
mov al,bl
|
||||
and al,0xf
|
||||
cmp al,10
|
||||
jl @f
|
||||
add al,'a'-'0'-10
|
||||
@@:
|
||||
add al,'0'
|
||||
mov byte[edi],al
|
||||
dec edi
|
||||
shr ebx,4
|
||||
loop .cycle
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
;---
|
||||
|
||||
macro png_warning h,txt
|
||||
{
|
||||
if txt eqtype ''
|
||||
local .end_t
|
||||
local .m_txt
|
||||
jmp .end_t
|
||||
.m_txt db txt,13,10,0
|
||||
.end_t:
|
||||
stdcall f_png_warning,h,.m_txt
|
||||
else
|
||||
stdcall f_png_warning,h,txt
|
||||
push eax ebx ecx
|
||||
mcall SF_BOARD,SSF_DEBUG_WRITE,13
|
||||
mcall ,,10
|
||||
pop ecx ebx eax
|
||||
end if
|
||||
}
|
||||
|
||||
macro png_app_warning h,txt
|
||||
{
|
||||
png_warning h,<txt>
|
||||
}
|
||||
|
||||
macro png_error h,txt
|
||||
{
|
||||
if txt eqtype ''
|
||||
local .end_t
|
||||
local .m_txt
|
||||
jmp .end_t
|
||||
.m_txt db txt,13,10,0
|
||||
.end_t:
|
||||
stdcall f_png_error,h,.m_txt
|
||||
else
|
||||
stdcall f_png_error,h,txt
|
||||
push eax ebx ecx
|
||||
mcall SF_BOARD,SSF_DEBUG_WRITE,13
|
||||
mcall ,,10
|
||||
pop ecx ebx eax
|
||||
end if
|
||||
}
|
||||
|
||||
macro png_debug n,txt
|
||||
{
|
||||
if DEBUG eq 1
|
||||
local .end_t
|
||||
local .m_txt
|
||||
jmp .end_t
|
||||
.m_txt db txt,13,10,0
|
||||
align 4
|
||||
.end_t:
|
||||
stdcall f_png_debug,n,.m_txt
|
||||
end if
|
||||
}
|
||||
|
||||
macro png_debug1 n,fmt,p1
|
||||
{
|
||||
if DEBUG eq 1
|
||||
local .end_t
|
||||
|
||||
if p1 eqtype ''
|
||||
local .m_txt1
|
||||
local .m_txt2
|
||||
jmp .end_t
|
||||
.m_txt1 db fmt,0
|
||||
.m_txt2 db p1,13,10,0
|
||||
align 4
|
||||
.end_t:
|
||||
stdcall dbg_print,.m_txt1,.m_txt2
|
||||
|
||||
else
|
||||
local .m_fmt
|
||||
jmp .end_t
|
||||
.m_fmt db fmt,13,10,0
|
||||
align 4
|
||||
.end_t:
|
||||
stdcall str_format_dbg, buf_param,.m_fmt,p1
|
||||
|
||||
end if
|
||||
end if
|
||||
}
|
||||
|
||||
;output:
|
||||
; eax = strlen
|
||||
align 4
|
||||
proc strlen, str1:dword
|
||||
mov eax,[str1]
|
||||
@@:
|
||||
cmp byte[eax],0
|
||||
je @f
|
||||
inc eax
|
||||
jmp @b
|
||||
@@:
|
||||
sub eax,[str1]
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc str_format_dbg, buf:dword, fmt:dword, p1:dword
|
||||
pushad
|
||||
mov esi,[fmt]
|
||||
mov edi,[buf]
|
||||
mov ecx,80-1
|
||||
.cycle0:
|
||||
lodsb
|
||||
cmp al,'%'
|
||||
jne .no_param
|
||||
lodsb
|
||||
dec ecx
|
||||
cmp al,0
|
||||
je .cycle0end
|
||||
cmp al,'d'
|
||||
je @f
|
||||
cmp al,'u'
|
||||
je @f
|
||||
cmp al,'l'
|
||||
je .end1
|
||||
jmp .end0
|
||||
.end1: ;%lu %lx
|
||||
lodsb
|
||||
dec ecx
|
||||
cmp al,'u'
|
||||
jne .end0
|
||||
@@:
|
||||
mov eax,[p1]
|
||||
stdcall convert_int_to_str,ecx
|
||||
xor al,al
|
||||
repne scasb
|
||||
dec edi
|
||||
.end0:
|
||||
loop .cycle0
|
||||
.no_param:
|
||||
stosb
|
||||
cmp al,0
|
||||
je .cycle0end
|
||||
loop .cycle0
|
||||
.cycle0end:
|
||||
xor al,al
|
||||
stosb
|
||||
stdcall dbg_print,txt_sp,[buf]
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
;input:
|
||||
; eax - число
|
||||
; edi - буфер для строки
|
||||
; len - длинна буфера
|
||||
;output:
|
||||
align 4
|
||||
proc convert_int_to_str, len:dword
|
||||
pushad
|
||||
mov esi,[len]
|
||||
add esi,edi
|
||||
dec esi
|
||||
call .str
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
.str:
|
||||
mov ecx,0x0a
|
||||
cmp eax,ecx
|
||||
jb @f
|
||||
xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
call .str
|
||||
pop eax
|
||||
@@:
|
||||
cmp edi,esi
|
||||
jge @f
|
||||
or al,0x30
|
||||
stosb
|
||||
mov byte[edi],0
|
||||
@@:
|
||||
ret
|
||||
|
||||
macro std_png_image_error n,txt
|
||||
{
|
||||
local .end_t
|
||||
local .m_txt
|
||||
jmp .end_t
|
||||
.m_txt db txt,13,10,0
|
||||
align 4
|
||||
.end_t:
|
||||
stdcall png_image_error,n,.m_txt
|
||||
}
|
||||
|
||||
|
||||
txt_zv db '*',0
|
||||
txt_sp db ' ',0
|
||||
txt_buf db '1234',0
|
||||
rd 1
|
||||
|
||||
buf_param rb 80
|
||||
|
||||
macro cStr dest,txt
|
||||
{
|
||||
local .end_t
|
||||
local .m_txt
|
||||
jmp .end_t
|
||||
align 4
|
||||
.m_txt db txt,0
|
||||
align 4
|
||||
.end_t:
|
||||
if dest eq
|
||||
mov eax,.m_txt
|
||||
else
|
||||
mov dest,.m_txt
|
||||
end if
|
||||
}
|
||||
|
||||
align 4
|
||||
proc f_png_warning, h:dword, m_txt:dword
|
||||
stdcall hex_in_str,txt_buf,[h],5
|
||||
mov byte[txt_buf+5],0
|
||||
stdcall dbg_print,txt_buf,[m_txt]
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc f_png_error, h:dword, m_txt:dword
|
||||
stdcall hex_in_str,txt_buf,[h],5
|
||||
mov byte[txt_buf+5],0
|
||||
stdcall dbg_print,txt_buf,[m_txt]
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc f_png_debug, n:dword, m_txt:dword
|
||||
stdcall dbg_print,txt_sp,[m_txt]
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc dbg_print, fun:dword, mes:dword
|
||||
pushad
|
||||
mov eax,SF_BOARD
|
||||
mov ebx,SSF_DEBUG_WRITE
|
||||
|
||||
mov esi,[fun]
|
||||
cmp esi,0
|
||||
je .end0
|
||||
@@:
|
||||
mov cl,byte[esi]
|
||||
int 0x40
|
||||
inc esi
|
||||
cmp byte[esi],0
|
||||
jne @b
|
||||
mov cl,':'
|
||||
int 0x40
|
||||
mov cl,' '
|
||||
int 0x40
|
||||
.end0:
|
||||
mov esi,[mes]
|
||||
cmp esi,0
|
||||
je .end_f
|
||||
@@:
|
||||
mov cl,byte[esi]
|
||||
cmp cl,0
|
||||
je .end_f
|
||||
int 0x40
|
||||
inc esi
|
||||
jmp @b
|
||||
.end_f:
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
;input:
|
||||
; zif - 1...8
|
||||
align 4
|
||||
proc hex_in_str, buf:dword,val:dword,zif:dword
|
||||
pushad
|
||||
mov edi,dword[buf]
|
||||
mov ecx,dword[zif]
|
||||
add edi,ecx
|
||||
dec edi
|
||||
mov ebx,dword[val]
|
||||
|
||||
.cycle:
|
||||
mov al,bl
|
||||
and al,0xf
|
||||
cmp al,10
|
||||
jl @f
|
||||
add al,'a'-'0'-10
|
||||
@@:
|
||||
add al,'0'
|
||||
mov byte[edi],al
|
||||
dec edi
|
||||
shr ebx,4
|
||||
loop .cycle
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
;---
|
||||
|
||||
macro png_warning h,txt
|
||||
{
|
||||
if txt eqtype ''
|
||||
local .end_t
|
||||
local .m_txt
|
||||
jmp .end_t
|
||||
.m_txt db txt,13,10,0
|
||||
.end_t:
|
||||
stdcall f_png_warning,h,.m_txt
|
||||
else
|
||||
stdcall f_png_warning,h,txt
|
||||
push eax ebx ecx
|
||||
mcall SF_BOARD,SSF_DEBUG_WRITE,13
|
||||
mcall ,,10
|
||||
pop ecx ebx eax
|
||||
end if
|
||||
}
|
||||
|
||||
macro png_app_warning h,txt
|
||||
{
|
||||
png_warning h,<txt>
|
||||
}
|
||||
|
||||
macro png_error h,txt
|
||||
{
|
||||
if txt eqtype ''
|
||||
local .end_t
|
||||
local .m_txt
|
||||
jmp .end_t
|
||||
.m_txt db txt,13,10,0
|
||||
.end_t:
|
||||
stdcall f_png_error,h,.m_txt
|
||||
else
|
||||
stdcall f_png_error,h,txt
|
||||
push eax ebx ecx
|
||||
mcall SF_BOARD,SSF_DEBUG_WRITE,13
|
||||
mcall ,,10
|
||||
pop ecx ebx eax
|
||||
end if
|
||||
}
|
||||
|
||||
macro png_debug n,txt
|
||||
{
|
||||
if DEBUG eq 1
|
||||
local .end_t
|
||||
local .m_txt
|
||||
jmp .end_t
|
||||
.m_txt db txt,13,10,0
|
||||
align 4
|
||||
.end_t:
|
||||
stdcall f_png_debug,n,.m_txt
|
||||
end if
|
||||
}
|
||||
|
||||
macro png_debug1 n,fmt,p1
|
||||
{
|
||||
if DEBUG eq 1
|
||||
local .end_t
|
||||
|
||||
if p1 eqtype ''
|
||||
local .m_txt1
|
||||
local .m_txt2
|
||||
jmp .end_t
|
||||
.m_txt1 db fmt,0
|
||||
.m_txt2 db p1,13,10,0
|
||||
align 4
|
||||
.end_t:
|
||||
stdcall dbg_print,.m_txt1,.m_txt2
|
||||
|
||||
else
|
||||
local .m_fmt
|
||||
jmp .end_t
|
||||
.m_fmt db fmt,13,10,0
|
||||
align 4
|
||||
.end_t:
|
||||
stdcall str_format_dbg, buf_param,.m_fmt,p1
|
||||
|
||||
end if
|
||||
end if
|
||||
}
|
||||
|
||||
;output:
|
||||
; eax = strlen
|
||||
align 4
|
||||
proc strlen, str1:dword
|
||||
mov eax,[str1]
|
||||
@@:
|
||||
cmp byte[eax],0
|
||||
je @f
|
||||
inc eax
|
||||
jmp @b
|
||||
@@:
|
||||
sub eax,[str1]
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
proc str_format_dbg, buf:dword, fmt:dword, p1:dword
|
||||
pushad
|
||||
mov esi,[fmt]
|
||||
mov edi,[buf]
|
||||
mov ecx,80-1
|
||||
.cycle0:
|
||||
lodsb
|
||||
cmp al,'%'
|
||||
jne .no_param
|
||||
lodsb
|
||||
dec ecx
|
||||
cmp al,0
|
||||
je .cycle0end
|
||||
cmp al,'d'
|
||||
je @f
|
||||
cmp al,'u'
|
||||
je @f
|
||||
cmp al,'l'
|
||||
je .end1
|
||||
jmp .end0
|
||||
.end1: ;%lu %lx
|
||||
lodsb
|
||||
dec ecx
|
||||
cmp al,'u'
|
||||
jne .end0
|
||||
@@:
|
||||
mov eax,[p1]
|
||||
stdcall convert_int_to_str,ecx
|
||||
xor al,al
|
||||
repne scasb
|
||||
dec edi
|
||||
.end0:
|
||||
loop .cycle0
|
||||
.no_param:
|
||||
stosb
|
||||
cmp al,0
|
||||
je .cycle0end
|
||||
loop .cycle0
|
||||
.cycle0end:
|
||||
xor al,al
|
||||
stosb
|
||||
stdcall dbg_print,txt_sp,[buf]
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
;input:
|
||||
; eax - число
|
||||
; edi - буфер для строки
|
||||
; len - длинна буфера
|
||||
;output:
|
||||
align 4
|
||||
proc convert_int_to_str, len:dword
|
||||
pushad
|
||||
mov esi,[len]
|
||||
add esi,edi
|
||||
dec esi
|
||||
call .str
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
align 4
|
||||
.str:
|
||||
mov ecx,0x0a
|
||||
cmp eax,ecx
|
||||
jb @f
|
||||
xor edx,edx
|
||||
div ecx
|
||||
push edx
|
||||
call .str
|
||||
pop eax
|
||||
@@:
|
||||
cmp edi,esi
|
||||
jge @f
|
||||
or al,0x30
|
||||
stosb
|
||||
mov byte[edi],0
|
||||
@@:
|
||||
ret
|
||||
|
||||
macro std_png_image_error n,txt
|
||||
{
|
||||
local .end_t
|
||||
local .m_txt
|
||||
jmp .end_t
|
||||
.m_txt db txt,13,10,0
|
||||
align 4
|
||||
.end_t:
|
||||
stdcall png_image_error,n,.m_txt
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,165 +1,165 @@
|
||||
|
||||
; pngwio.asm - functions for data output
|
||||
|
||||
; Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
; Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
||||
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
||||
; This code is released under the libpng license.
|
||||
; For conditions of distribution and use, see the disclaimer
|
||||
; and license in png.inc
|
||||
|
||||
; This file provides a location for all output. Users who need
|
||||
; special handling are expected to write functions that have the same
|
||||
; arguments as these and perform similar functions, but that possibly
|
||||
; use different output methods. Note that you shouldn't change these
|
||||
; functions, but rather write replacement functions and then change
|
||||
; them at run time with png_set_write_fn(...).
|
||||
|
||||
|
||||
; Write the data to whatever output you are using. The default routine
|
||||
; writes to a file pointer. Note that this routine sometimes gets called
|
||||
; with very small lengths, so you should implement some kind of simple
|
||||
; buffering if you are using unbuffered writes. This should never be asked
|
||||
; to write more than 64K on a 16-bit machine.
|
||||
|
||||
;void (png_structrp png_ptr, bytep data, png_size_t length)
|
||||
align 4
|
||||
proc png_write_data uses edi, png_ptr:dword, p2data:dword, length:dword
|
||||
; NOTE: write_data_fn must not change the buffer!
|
||||
mov edi,[png_ptr]
|
||||
cmp dword[edi+png_struct.write_data_fn],0
|
||||
je @f ;if (..!=0)
|
||||
stdcall dword[edi+png_struct.write_data_fn], edi, [p2data], [length]
|
||||
jmp .end_f
|
||||
@@: ;else
|
||||
png_error edi, 'Call to NULL write function'
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; 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
|
||||
; write_data function and use it at run time with png_set_write_fn(), rather
|
||||
; than changing the library.
|
||||
|
||||
;void (png_structp png_ptr, bytep data, png_size_t length)
|
||||
align 4
|
||||
proc png_default_write_data uses eax edi, png_ptr:dword, p2data:dword, length:dword
|
||||
; png_size_t check;
|
||||
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je .end_f ;if (..==0) return
|
||||
|
||||
; check = fwrite(p2data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
|
||||
|
||||
; if (check != length)
|
||||
; png_error(png_ptr, "Write Error");
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; This function is called to output any data pending writing (normally
|
||||
; to disk). After png_flush is called, there should be no data pending
|
||||
; writing in any buffers.
|
||||
|
||||
;void (png_structrp png_ptr)
|
||||
align 4
|
||||
proc png_flush uses edi, png_ptr:dword
|
||||
mov edi,[png_ptr]
|
||||
cmp dword[edi+png_struct.output_flush_fn],0
|
||||
je @f ;if (..!=..)
|
||||
stdcall dword[edi+png_struct.output_flush_fn],edi
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
;void (png_structp png_ptr)
|
||||
align 4
|
||||
proc png_default_flush uses eax edi, png_ptr:dword
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..==0) return
|
||||
;;; stdcall fflush, [edi+png_struct.io_ptr]
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
; This function allows the application to supply new output functions for
|
||||
; libpng if standard C streams aren't being used.
|
||||
|
||||
; This function takes as its arguments:
|
||||
; png_ptr - pointer to a png output data structure
|
||||
; io_ptr - pointer to user supplied structure containing info about
|
||||
; the output functions. May be NULL.
|
||||
; write_data_fn - pointer to a new output function that takes as its
|
||||
; arguments a pointer to a png_struct, a pointer to
|
||||
; data to be written, and a 32-bit unsigned int that is
|
||||
; the number of bytes to be written. The new write
|
||||
; function should call png_error(png_ptr, "Error msg")
|
||||
; to exit and output any fatal error messages. May be
|
||||
; NULL, in which case libpng's default function will
|
||||
; be used.
|
||||
; flush_data_fn - pointer to a new flush function that takes as its
|
||||
; arguments a pointer to a png_struct. After a call to
|
||||
; the flush function, there should be no data in any buffers
|
||||
; or pending transmission. If the output method doesn't do
|
||||
; any buffering of output, a function prototype must still be
|
||||
; supplied although it doesn't have to do anything. If
|
||||
; PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
||||
; time, output_flush_fn will be ignored, although it must be
|
||||
; supplied for compatibility. May be NULL, in which case
|
||||
; libpng's default function will be used, if
|
||||
; PNG_WRITE_FLUSH_SUPPORTED is defined. This is not
|
||||
; a good idea if io_ptr does not point to a standard
|
||||
; *FILE structure.
|
||||
|
||||
;void (png_structrp png_ptr, voidp io_ptr,
|
||||
; png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
align 4
|
||||
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]
|
||||
cmp edi,0
|
||||
je .end_f ;if (..==0) return
|
||||
|
||||
mov eax,[io_ptr]
|
||||
mov [edi+png_struct.io_ptr],eax
|
||||
|
||||
if PNG_STDIO_SUPPORTED eq 1
|
||||
mov eax,png_default_write_data ;else
|
||||
cmp dword[write_data_fn],0
|
||||
je @f ;if (..!=0)
|
||||
mov eax,[write_data_fn]
|
||||
@@:
|
||||
else
|
||||
mov eax,[write_data_fn]
|
||||
end if
|
||||
mov [edi+png_struct.write_data_fn],eax
|
||||
|
||||
if PNG_WRITE_FLUSH_SUPPORTED eq 1
|
||||
if PNG_STDIO_SUPPORTED eq 1
|
||||
mov eax,[png_default_flush] ;else
|
||||
cmp dword[output_flush_fn],0
|
||||
je @f ;if (..!=0)
|
||||
mov eax,[output_flush_fn]
|
||||
@@:
|
||||
else
|
||||
mov eax,[output_flush_fn]
|
||||
end if
|
||||
mov [edi+png_struct.output_flush_fn],eax
|
||||
end if ;WRITE_FLUSH
|
||||
|
||||
if PNG_READ_SUPPORTED eq 1
|
||||
; It is an error to read while writing a png file
|
||||
cmp dword[edi+png_struct.read_data_fn],0
|
||||
je @f ;if (..!=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'>
|
||||
@@:
|
||||
end if
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; pngwio.asm - functions for data output
|
||||
|
||||
; Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
; Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
||||
; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
|
||||
; This code is released under the libpng license.
|
||||
; For conditions of distribution and use, see the disclaimer
|
||||
; and license in png.inc
|
||||
|
||||
; This file provides a location for all output. Users who need
|
||||
; special handling are expected to write functions that have the same
|
||||
; arguments as these and perform similar functions, but that possibly
|
||||
; use different output methods. Note that you shouldn't change these
|
||||
; functions, but rather write replacement functions and then change
|
||||
; them at run time with png_set_write_fn(...).
|
||||
|
||||
|
||||
; Write the data to whatever output you are using. The default routine
|
||||
; writes to a file pointer. Note that this routine sometimes gets called
|
||||
; with very small lengths, so you should implement some kind of simple
|
||||
; buffering if you are using unbuffered writes. This should never be asked
|
||||
; to write more than 64K on a 16-bit machine.
|
||||
|
||||
;void (png_structrp png_ptr, bytep data, png_size_t length)
|
||||
align 4
|
||||
proc png_write_data uses edi, png_ptr:dword, p2data:dword, length:dword
|
||||
; NOTE: write_data_fn must not change the buffer!
|
||||
mov edi,[png_ptr]
|
||||
cmp dword[edi+png_struct.write_data_fn],0
|
||||
je @f ;if (..!=0)
|
||||
stdcall dword[edi+png_struct.write_data_fn], edi, [p2data], [length]
|
||||
jmp .end_f
|
||||
@@: ;else
|
||||
png_error edi, 'Call to NULL write function'
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; 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
|
||||
; write_data function and use it at run time with png_set_write_fn(), rather
|
||||
; than changing the library.
|
||||
|
||||
;void (png_structp png_ptr, bytep data, png_size_t length)
|
||||
align 4
|
||||
proc png_default_write_data uses eax edi, png_ptr:dword, p2data:dword, length:dword
|
||||
; png_size_t check;
|
||||
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je .end_f ;if (..==0) return
|
||||
|
||||
; check = fwrite(p2data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
|
||||
|
||||
; if (check != length)
|
||||
; png_error(png_ptr, "Write Error");
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
||||
; This function is called to output any data pending writing (normally
|
||||
; to disk). After png_flush is called, there should be no data pending
|
||||
; writing in any buffers.
|
||||
|
||||
;void (png_structrp png_ptr)
|
||||
align 4
|
||||
proc png_flush uses edi, png_ptr:dword
|
||||
mov edi,[png_ptr]
|
||||
cmp dword[edi+png_struct.output_flush_fn],0
|
||||
je @f ;if (..!=..)
|
||||
stdcall dword[edi+png_struct.output_flush_fn],edi
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
;void (png_structp png_ptr)
|
||||
align 4
|
||||
proc png_default_flush uses eax edi, png_ptr:dword
|
||||
mov edi,[png_ptr]
|
||||
cmp edi,0
|
||||
je @f ;if (..==0) return
|
||||
;;; stdcall fflush, [edi+png_struct.io_ptr]
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
; This function allows the application to supply new output functions for
|
||||
; libpng if standard C streams aren't being used.
|
||||
|
||||
; This function takes as its arguments:
|
||||
; png_ptr - pointer to a png output data structure
|
||||
; io_ptr - pointer to user supplied structure containing info about
|
||||
; the output functions. May be NULL.
|
||||
; write_data_fn - pointer to a new output function that takes as its
|
||||
; arguments a pointer to a png_struct, a pointer to
|
||||
; data to be written, and a 32-bit unsigned int that is
|
||||
; the number of bytes to be written. The new write
|
||||
; function should call png_error(png_ptr, "Error msg")
|
||||
; to exit and output any fatal error messages. May be
|
||||
; NULL, in which case libpng's default function will
|
||||
; be used.
|
||||
; flush_data_fn - pointer to a new flush function that takes as its
|
||||
; arguments a pointer to a png_struct. After a call to
|
||||
; the flush function, there should be no data in any buffers
|
||||
; or pending transmission. If the output method doesn't do
|
||||
; any buffering of output, a function prototype must still be
|
||||
; supplied although it doesn't have to do anything. If
|
||||
; PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile
|
||||
; time, output_flush_fn will be ignored, although it must be
|
||||
; supplied for compatibility. May be NULL, in which case
|
||||
; libpng's default function will be used, if
|
||||
; PNG_WRITE_FLUSH_SUPPORTED is defined. This is not
|
||||
; a good idea if io_ptr does not point to a standard
|
||||
; *FILE structure.
|
||||
|
||||
;void (png_structrp png_ptr, voidp io_ptr,
|
||||
; png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
|
||||
align 4
|
||||
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]
|
||||
cmp edi,0
|
||||
je .end_f ;if (..==0) return
|
||||
|
||||
mov eax,[io_ptr]
|
||||
mov [edi+png_struct.io_ptr],eax
|
||||
|
||||
if PNG_STDIO_SUPPORTED eq 1
|
||||
mov eax,png_default_write_data ;else
|
||||
cmp dword[write_data_fn],0
|
||||
je @f ;if (..!=0)
|
||||
mov eax,[write_data_fn]
|
||||
@@:
|
||||
else
|
||||
mov eax,[write_data_fn]
|
||||
end if
|
||||
mov [edi+png_struct.write_data_fn],eax
|
||||
|
||||
if PNG_WRITE_FLUSH_SUPPORTED eq 1
|
||||
if PNG_STDIO_SUPPORTED eq 1
|
||||
mov eax,[png_default_flush] ;else
|
||||
cmp dword[output_flush_fn],0
|
||||
je @f ;if (..!=0)
|
||||
mov eax,[output_flush_fn]
|
||||
@@:
|
||||
else
|
||||
mov eax,[output_flush_fn]
|
||||
end if
|
||||
mov [edi+png_struct.output_flush_fn],eax
|
||||
end if ;WRITE_FLUSH
|
||||
|
||||
if PNG_READ_SUPPORTED eq 1
|
||||
; It is an error to read while writing a png file
|
||||
cmp dword[edi+png_struct.read_data_fn],0
|
||||
je @f ;if (..!=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'>
|
||||
@@:
|
||||
end if
|
||||
.end_f:
|
||||
ret
|
||||
endp
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,288 +1,288 @@
|
||||
;;================================================================================================;;
|
||||
;;//// tga.asm //// (c) Nable, 2007-2008, (c) dunkaist, 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; References: ;;
|
||||
;; 1. Hiview 1.2 by Mohammad A. REZAEI ;;
|
||||
;; 2. Truevision TGA FILE FORMAT SPECIFICATION Version 2.0 ;;
|
||||
;; Technical Manual Version 2.2 January, 1991 ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
include 'tga.inc'
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.is.tga _data, _length ;//////////////////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Determine if raw data could be decoded (is in Targa format) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = false / true ;;
|
||||
;;================================================================================================;;
|
||||
push ebx
|
||||
cmp [_length], 18
|
||||
jbe .nope
|
||||
mov ebx, [_data]
|
||||
mov eax, dword[ebx + tga_header.colormap_type]
|
||||
cmp al, 1
|
||||
ja .nope
|
||||
cmp ah, 11
|
||||
ja .nope
|
||||
cmp ah, 9
|
||||
jae .cont1
|
||||
cmp ah, 3
|
||||
ja .nope
|
||||
.cont1:
|
||||
mov eax, dword[ebx + tga_header.image_spec.depth]
|
||||
test eax, 111b ; bpp must be 8, 15, 16, 24 or 32
|
||||
jnz .maybe15
|
||||
shr al, 3
|
||||
cmp al, 4
|
||||
ja .nope
|
||||
jmp .cont2
|
||||
.maybe15:
|
||||
cmp al, 15
|
||||
jne .nope
|
||||
.cont2: ; continue testing
|
||||
movzx eax, byte[ebx + tga_header.colormap_spec.entry_size] ; palette bpp
|
||||
cmp eax, 0
|
||||
je .yep
|
||||
cmp eax, 16
|
||||
je .yep
|
||||
cmp eax, 24
|
||||
je .yep
|
||||
cmp eax, 32
|
||||
je .yep
|
||||
.nope:
|
||||
xor eax, eax
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
.yep:
|
||||
xor eax, eax
|
||||
inc eax
|
||||
pop ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.tga _data, _length, _options ;////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in Targa format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
locals
|
||||
width dd ?
|
||||
height dd ?
|
||||
bytes_per_pixel dd ?
|
||||
retvalue dd ?
|
||||
endl
|
||||
push ebx esi edi
|
||||
mov ebx, [_data]
|
||||
movzx esi, byte[ebx]
|
||||
lea esi, [esi + ebx + sizeof.tga_header] ; skip comment and header
|
||||
mov edx, dword[ebx + tga_header.image_spec.width]
|
||||
movzx ecx, dx ; ecx = width
|
||||
shr edx, 16 ; edx = height
|
||||
mov [width], ecx
|
||||
mov [height], edx
|
||||
movzx eax, byte[ebx + tga_header.image_spec.depth]
|
||||
add eax, 7
|
||||
shr eax, 3
|
||||
mov [bytes_per_pixel], eax
|
||||
movzx eax, byte[ebx + tga_header.image_spec.depth]
|
||||
|
||||
cmp eax, 8
|
||||
jne @f
|
||||
mov eax, Image.bpp8i
|
||||
jmp .type_defined
|
||||
@@:
|
||||
cmp eax, 15
|
||||
jne @f
|
||||
mov eax, Image.bpp15
|
||||
jmp .type_defined
|
||||
@@:
|
||||
cmp eax, 16
|
||||
jne @f
|
||||
mov eax, Image.bpp15 ; 16bpp tga images are really 15bpp ARGB
|
||||
jmp .type_defined
|
||||
@@:
|
||||
cmp eax, 24
|
||||
jne @f
|
||||
mov eax, Image.bpp24
|
||||
jmp .type_defined
|
||||
@@:
|
||||
cmp eax, 32
|
||||
jne @f
|
||||
mov eax, Image.bpp32
|
||||
jmp .type_defined
|
||||
@@:
|
||||
.type_defined:
|
||||
stdcall img.create, ecx, edx, eax
|
||||
mov [retvalue], eax
|
||||
test eax, eax ; failed to allocate?
|
||||
jz .done ; then exit
|
||||
mov ebx, eax
|
||||
cmp dword[ebx + Image.Type], Image.bpp8i
|
||||
jne .palette_parsed
|
||||
mov edi, [ebx + Image.Palette]
|
||||
mov ecx, [_data]
|
||||
cmp byte[ecx + tga_header.image_type], 3 ; we also have grayscale subtype
|
||||
jz .write_grayscale_palette ; that don't hold palette in file
|
||||
cmp byte[ecx + tga_header.image_type], 11
|
||||
jz .write_grayscale_palette
|
||||
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
|
||||
cmp eax, 24
|
||||
je .24bpp_palette
|
||||
cmp eax, 16
|
||||
je .16bpp_palette
|
||||
rep movsd ; else they are 32 bpp
|
||||
jmp .palette_parsed
|
||||
.write_grayscale_palette:
|
||||
mov ecx, 0x100
|
||||
xor eax, eax
|
||||
@@:
|
||||
stosd
|
||||
add eax, 0x010101
|
||||
loop @b
|
||||
jmp .palette_parsed
|
||||
.16bpp_palette: ; FIXME: code copypasted from img.do_rgb, should use img.convert
|
||||
push ebx edx ebp
|
||||
@@:
|
||||
movzx eax, word[esi]
|
||||
mov ebx, eax
|
||||
add esi, 2
|
||||
and eax, (0x1F) or (0x1F shl 10)
|
||||
and ebx, 0x1F shl 5
|
||||
lea edx, [eax + eax]
|
||||
shr al, 2
|
||||
mov ebp, ebx
|
||||
shr ebx, 2
|
||||
shr ah, 4
|
||||
shl dl, 2
|
||||
shr ebp, 7
|
||||
add eax, edx
|
||||
add ebx, ebp
|
||||
mov [edi], al
|
||||
mov [edi + 1], bl
|
||||
mov [edi + 2], ah
|
||||
add edi, 4
|
||||
loop @b
|
||||
pop ebp edx ebx
|
||||
jmp .palette_parsed
|
||||
|
||||
.24bpp_palette:
|
||||
@@:
|
||||
lodsd
|
||||
dec esi
|
||||
and eax, 0xffffff
|
||||
stosd
|
||||
loop @b
|
||||
.palette_parsed:
|
||||
mov edi, [ebx + Image.Data]
|
||||
mov ebx, [width]
|
||||
imul ebx, [height]
|
||||
mov edx, [bytes_per_pixel]
|
||||
mov eax, [_data]
|
||||
test byte[eax + tga_header.image_type], 0x08
|
||||
jz .uncompressed
|
||||
.next_rle_packet:
|
||||
xor eax, eax
|
||||
lodsb
|
||||
btr ax, 7 ; Run-length packet?
|
||||
jnc .raw_packet
|
||||
add eax, 1
|
||||
sub ebx, eax
|
||||
@@:
|
||||
mov ecx, edx
|
||||
rep movsb
|
||||
sub esi, edx
|
||||
sub eax, 1
|
||||
jnz @b
|
||||
add esi, edx
|
||||
test ebx, ebx
|
||||
jnz .next_rle_packet
|
||||
jmp .done
|
||||
.raw_packet:
|
||||
mov ecx, eax
|
||||
add ecx, 1
|
||||
sub ebx, ecx
|
||||
imul ecx, edx
|
||||
rep movsb
|
||||
test ebx, ebx
|
||||
jnz .next_rle_packet
|
||||
.uncompressed:
|
||||
imul edx, ebx
|
||||
mov ecx, edx
|
||||
rep movsb
|
||||
.done:
|
||||
xor ebx, ebx
|
||||
mov esi, [_data]
|
||||
test byte[esi + tga_header.image_spec.descriptor], TGA_START_TOP
|
||||
jnz @f
|
||||
or ebx, FLIP_VERTICAL
|
||||
@@:
|
||||
test byte[esi + tga_header.image_spec.descriptor], TGA_START_RIGHT
|
||||
jz @f
|
||||
or ebx, FLIP_HORIZONTAL
|
||||
@@:
|
||||
test ebx, ebx
|
||||
jz @f
|
||||
stdcall img.flip, [retvalue], ebx
|
||||
@@:
|
||||
pop edi esi ebx
|
||||
mov eax, [retvalue]
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode.tga _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in Targa format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _img = pointer to image ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to encoded data ;;
|
||||
;< _p_length = encoded data length ;;
|
||||
;;================================================================================================;;
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below are private procs you should never call directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below is private data you should never use directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;;================================================================================================;;
|
||||
;;//// tga.asm //// (c) Nable, 2007-2008, (c) dunkaist, 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; References: ;;
|
||||
;; 1. Hiview 1.2 by Mohammad A. REZAEI ;;
|
||||
;; 2. Truevision TGA FILE FORMAT SPECIFICATION Version 2.0 ;;
|
||||
;; Technical Manual Version 2.2 January, 1991 ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
include 'tga.inc'
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.is.tga _data, _length ;//////////////////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Determine if raw data could be decoded (is in Targa format) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = false / true ;;
|
||||
;;================================================================================================;;
|
||||
push ebx
|
||||
cmp [_length], 18
|
||||
jbe .nope
|
||||
mov ebx, [_data]
|
||||
mov eax, dword[ebx + tga_header.colormap_type]
|
||||
cmp al, 1
|
||||
ja .nope
|
||||
cmp ah, 11
|
||||
ja .nope
|
||||
cmp ah, 9
|
||||
jae .cont1
|
||||
cmp ah, 3
|
||||
ja .nope
|
||||
.cont1:
|
||||
mov eax, dword[ebx + tga_header.image_spec.depth]
|
||||
test eax, 111b ; bpp must be 8, 15, 16, 24 or 32
|
||||
jnz .maybe15
|
||||
shr al, 3
|
||||
cmp al, 4
|
||||
ja .nope
|
||||
jmp .cont2
|
||||
.maybe15:
|
||||
cmp al, 15
|
||||
jne .nope
|
||||
.cont2: ; continue testing
|
||||
movzx eax, byte[ebx + tga_header.colormap_spec.entry_size] ; palette bpp
|
||||
cmp eax, 0
|
||||
je .yep
|
||||
cmp eax, 16
|
||||
je .yep
|
||||
cmp eax, 24
|
||||
je .yep
|
||||
cmp eax, 32
|
||||
je .yep
|
||||
.nope:
|
||||
xor eax, eax
|
||||
pop ebx
|
||||
ret
|
||||
|
||||
.yep:
|
||||
xor eax, eax
|
||||
inc eax
|
||||
pop ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.tga _data, _length, _options ;////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in Targa format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
locals
|
||||
width dd ?
|
||||
height dd ?
|
||||
bytes_per_pixel dd ?
|
||||
retvalue dd ?
|
||||
endl
|
||||
push ebx esi edi
|
||||
mov ebx, [_data]
|
||||
movzx esi, byte[ebx]
|
||||
lea esi, [esi + ebx + sizeof.tga_header] ; skip comment and header
|
||||
mov edx, dword[ebx + tga_header.image_spec.width]
|
||||
movzx ecx, dx ; ecx = width
|
||||
shr edx, 16 ; edx = height
|
||||
mov [width], ecx
|
||||
mov [height], edx
|
||||
movzx eax, byte[ebx + tga_header.image_spec.depth]
|
||||
add eax, 7
|
||||
shr eax, 3
|
||||
mov [bytes_per_pixel], eax
|
||||
movzx eax, byte[ebx + tga_header.image_spec.depth]
|
||||
|
||||
cmp eax, 8
|
||||
jne @f
|
||||
mov eax, Image.bpp8i
|
||||
jmp .type_defined
|
||||
@@:
|
||||
cmp eax, 15
|
||||
jne @f
|
||||
mov eax, Image.bpp15
|
||||
jmp .type_defined
|
||||
@@:
|
||||
cmp eax, 16
|
||||
jne @f
|
||||
mov eax, Image.bpp15 ; 16bpp tga images are really 15bpp ARGB
|
||||
jmp .type_defined
|
||||
@@:
|
||||
cmp eax, 24
|
||||
jne @f
|
||||
mov eax, Image.bpp24
|
||||
jmp .type_defined
|
||||
@@:
|
||||
cmp eax, 32
|
||||
jne @f
|
||||
mov eax, Image.bpp32
|
||||
jmp .type_defined
|
||||
@@:
|
||||
.type_defined:
|
||||
stdcall img.create, ecx, edx, eax
|
||||
mov [retvalue], eax
|
||||
test eax, eax ; failed to allocate?
|
||||
jz .done ; then exit
|
||||
mov ebx, eax
|
||||
cmp dword[ebx + Image.Type], Image.bpp8i
|
||||
jne .palette_parsed
|
||||
mov edi, [ebx + Image.Palette]
|
||||
mov ecx, [_data]
|
||||
cmp byte[ecx + tga_header.image_type], 3 ; we also have grayscale subtype
|
||||
jz .write_grayscale_palette ; that don't hold palette in file
|
||||
cmp byte[ecx + tga_header.image_type], 11
|
||||
jz .write_grayscale_palette
|
||||
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
|
||||
cmp eax, 24
|
||||
je .24bpp_palette
|
||||
cmp eax, 16
|
||||
je .16bpp_palette
|
||||
rep movsd ; else they are 32 bpp
|
||||
jmp .palette_parsed
|
||||
.write_grayscale_palette:
|
||||
mov ecx, 0x100
|
||||
xor eax, eax
|
||||
@@:
|
||||
stosd
|
||||
add eax, 0x010101
|
||||
loop @b
|
||||
jmp .palette_parsed
|
||||
.16bpp_palette: ; FIXME: code copypasted from img.do_rgb, should use img.convert
|
||||
push ebx edx ebp
|
||||
@@:
|
||||
movzx eax, word[esi]
|
||||
mov ebx, eax
|
||||
add esi, 2
|
||||
and eax, (0x1F) or (0x1F shl 10)
|
||||
and ebx, 0x1F shl 5
|
||||
lea edx, [eax + eax]
|
||||
shr al, 2
|
||||
mov ebp, ebx
|
||||
shr ebx, 2
|
||||
shr ah, 4
|
||||
shl dl, 2
|
||||
shr ebp, 7
|
||||
add eax, edx
|
||||
add ebx, ebp
|
||||
mov [edi], al
|
||||
mov [edi + 1], bl
|
||||
mov [edi + 2], ah
|
||||
add edi, 4
|
||||
loop @b
|
||||
pop ebp edx ebx
|
||||
jmp .palette_parsed
|
||||
|
||||
.24bpp_palette:
|
||||
@@:
|
||||
lodsd
|
||||
dec esi
|
||||
and eax, 0xffffff
|
||||
stosd
|
||||
loop @b
|
||||
.palette_parsed:
|
||||
mov edi, [ebx + Image.Data]
|
||||
mov ebx, [width]
|
||||
imul ebx, [height]
|
||||
mov edx, [bytes_per_pixel]
|
||||
mov eax, [_data]
|
||||
test byte[eax + tga_header.image_type], 0x08
|
||||
jz .uncompressed
|
||||
.next_rle_packet:
|
||||
xor eax, eax
|
||||
lodsb
|
||||
btr ax, 7 ; Run-length packet?
|
||||
jnc .raw_packet
|
||||
add eax, 1
|
||||
sub ebx, eax
|
||||
@@:
|
||||
mov ecx, edx
|
||||
rep movsb
|
||||
sub esi, edx
|
||||
sub eax, 1
|
||||
jnz @b
|
||||
add esi, edx
|
||||
test ebx, ebx
|
||||
jnz .next_rle_packet
|
||||
jmp .done
|
||||
.raw_packet:
|
||||
mov ecx, eax
|
||||
add ecx, 1
|
||||
sub ebx, ecx
|
||||
imul ecx, edx
|
||||
rep movsb
|
||||
test ebx, ebx
|
||||
jnz .next_rle_packet
|
||||
.uncompressed:
|
||||
imul edx, ebx
|
||||
mov ecx, edx
|
||||
rep movsb
|
||||
.done:
|
||||
xor ebx, ebx
|
||||
mov esi, [_data]
|
||||
test byte[esi + tga_header.image_spec.descriptor], TGA_START_TOP
|
||||
jnz @f
|
||||
or ebx, FLIP_VERTICAL
|
||||
@@:
|
||||
test byte[esi + tga_header.image_spec.descriptor], TGA_START_RIGHT
|
||||
jz @f
|
||||
or ebx, FLIP_HORIZONTAL
|
||||
@@:
|
||||
test ebx, ebx
|
||||
jz @f
|
||||
stdcall img.flip, [retvalue], ebx
|
||||
@@:
|
||||
pop edi esi ebx
|
||||
mov eax, [retvalue]
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode.tga _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in Targa format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _img = pointer to image ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to encoded data ;;
|
||||
;< _p_length = encoded data length ;;
|
||||
;;================================================================================================;;
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below are private procs you should never call directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below is private data you should never use directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
@ -1,44 +1,44 @@
|
||||
;;================================================================================================;;
|
||||
;;//// tga.inc //// (c) Nable, 2007-2008, (c) dunkaist, 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
struct tga_colormap_spec
|
||||
first_entry_index dw ?
|
||||
colormap_length dw ?
|
||||
entry_size db ?
|
||||
ends
|
||||
|
||||
struct tga_image_spec
|
||||
x_origin dw ?
|
||||
y_origin dw ?
|
||||
width dw ?
|
||||
height dw ?
|
||||
depth db ?
|
||||
descriptor db ?
|
||||
ends
|
||||
|
||||
struct tga_header
|
||||
id_length db ?
|
||||
colormap_type db ?
|
||||
image_type db ?
|
||||
colormap_spec tga_colormap_spec
|
||||
image_spec tga_image_spec
|
||||
ends
|
||||
|
||||
TGA_START_TOP = 0x20
|
||||
TGA_START_RIGHT = 0x10
|
||||
;;================================================================================================;;
|
||||
;;//// tga.inc //// (c) Nable, 2007-2008, (c) dunkaist, 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
struct tga_colormap_spec
|
||||
first_entry_index dw ?
|
||||
colormap_length dw ?
|
||||
entry_size db ?
|
||||
ends
|
||||
|
||||
struct tga_image_spec
|
||||
x_origin dw ?
|
||||
y_origin dw ?
|
||||
width dw ?
|
||||
height dw ?
|
||||
depth db ?
|
||||
descriptor db ?
|
||||
ends
|
||||
|
||||
struct tga_header
|
||||
id_length db ?
|
||||
colormap_type db ?
|
||||
image_type db ?
|
||||
colormap_spec tga_colormap_spec
|
||||
image_spec tga_image_spec
|
||||
ends
|
||||
|
||||
TGA_START_TOP = 0x20
|
||||
TGA_START_RIGHT = 0x10
|
||||
|
@ -29,10 +29,6 @@
|
||||
include 'xcf.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
|
||||
|
||||
;;================================================================================================;;
|
||||
@ -1616,10 +1612,6 @@ endl
|
||||
ret
|
||||
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 15, xcf._.parse_properties.15
|
||||
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:
|
||||
|
@ -1,257 +1,257 @@
|
||||
;;================================================================================================;;
|
||||
;;//// z80.asm //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; References: ;;
|
||||
;; 1. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
include 'z80.inc'
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.is.z80 _data, _length ;//////////////////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Determine if raw data could be decoded (is in z80 screen format) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = false / true ;;
|
||||
;;================================================================================================;;
|
||||
xor eax,eax
|
||||
cmp [_length],6929
|
||||
setz al
|
||||
je @f
|
||||
cmp [_length],6912
|
||||
setz al
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.z80 _data, _length, _options ;////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in z80 screen format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
;---------------------------------------------------------------------------------------------------
|
||||
;During the decoding:
|
||||
;bl - PixelLeft (this means how much pixels left to put in current string)
|
||||
;bh - CurrentString
|
||||
;High half of ebx - use DualStos (two frames per one pixel_write)
|
||||
;cl - PixelColorIndexInPalette
|
||||
;ch - BackgroundColorIndexInPalette
|
||||
;High half of ecx - blinking flag
|
||||
;edx - address of current attribute byte
|
||||
;---------------------------------------------------------------------------------------------------
|
||||
locals
|
||||
frame1 dd ?
|
||||
OffsetIn2ndFrame dd ?
|
||||
endl
|
||||
xor eax,eax
|
||||
pushad
|
||||
cld ;paranoia
|
||||
stdcall img.create,256,192,Image.bpp8i
|
||||
test eax,eax
|
||||
jz img.decode.z80.locret ;test if allocation failed
|
||||
mov [frame1],eax
|
||||
mov esi,z80._._16color_palette
|
||||
mov ecx,16
|
||||
mov edi,[eax+Image.Palette]
|
||||
rep movsd ;write palette for the first frame
|
||||
mov esi,[_data]
|
||||
cmp [_length],6929
|
||||
jne @f
|
||||
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
|
||||
;if no - we'll produce statical single image
|
||||
mov ecx,768
|
||||
lea edx,[esi+6912-768];edx points to attribute area
|
||||
xor ebx,ebx ;begin from <0,0> (for further decoding)
|
||||
@@:
|
||||
test byte[edx+ecx-1],z80.BlinkFlag ;such addressing is a good optimisation
|
||||
;(as I hope), edx is unchanged
|
||||
jnz .decode_z80_with_blinking
|
||||
loop @b
|
||||
.decode_z80_without_blinking:
|
||||
jmp .decode_z80_main_stage
|
||||
|
||||
.decode_z80_with_blinking:
|
||||
or ebx,0xFFFF0000 ;use DualStos
|
||||
mov ecx,eax ;eax still points to the first frame
|
||||
stdcall img.create,256,192,Image.bpp8i
|
||||
test eax,eax
|
||||
jz img.decode.z80.failed
|
||||
mov [eax+Image.Previous],ecx
|
||||
mov [ecx+Image.Next],eax
|
||||
mov esi,z80._._16color_palette
|
||||
mov ecx,16
|
||||
mov edi,[eax+Image.Palette]
|
||||
rep movsd ;write palette for the second frame
|
||||
mov eax,[eax+Image.Data]
|
||||
mov [OffsetIn2ndFrame],eax
|
||||
;-------------------------------------------------------------------------------
|
||||
.decode_z80_main_stage:
|
||||
;2nd stage - convert z80 screen to 8bpp image with palette
|
||||
.decode_z80_main_stage_main_loop:
|
||||
test bl,7
|
||||
jnz .decode_z80_main_stage_put_now
|
||||
|
||||
._z80_update_attributes:
|
||||
movsx ecx,byte[edx] ;note that BlinkFlag is the highest bit in attribute
|
||||
;byte, so ecx's highest bit is set automatically
|
||||
shl ecx,5
|
||||
shr cl,5
|
||||
and ch,0xF
|
||||
test ch,1000b
|
||||
jz @f
|
||||
or ecx,1000b ;it has the same size with 'or cl,1000b' but could be faster
|
||||
@@:
|
||||
inc edx
|
||||
|
||||
lodsb
|
||||
mov ah,al
|
||||
|
||||
.decode_z80_main_stage_put_now:
|
||||
shl ah,1
|
||||
;-------------------------------------------------------------------------------
|
||||
._z80_put_pixel:
|
||||
;In: CF - put pixel with color CL, !CF - pixel with color CH
|
||||
;High parts of ebx and ecx - as described above
|
||||
mov al,cl ;'mov' doesn't affect flags
|
||||
jc @f
|
||||
mov al,ch
|
||||
@@:
|
||||
stosb ;'stosb' doesn't affect flags
|
||||
|
||||
test ebx,ebx
|
||||
jns @f
|
||||
test ecx,ecx
|
||||
jns .1
|
||||
mov al,ch
|
||||
.1:
|
||||
xchg [OffsetIn2ndFrame],edi
|
||||
stosb
|
||||
xchg [OffsetIn2ndFrame],edi
|
||||
@@:
|
||||
inc bl ;next pixel
|
||||
jz .decode_z80_main_stage_row_finished
|
||||
jmp .decode_z80_main_stage_main_loop
|
||||
;-------------------------------------------------------------------------------
|
||||
.decode_z80_main_stage_row_finished:
|
||||
cmp bh,191 ;is image finished?
|
||||
jb .decode_z80_main_stage_image_not_finished ;no.
|
||||
.decode_z80_finish:
|
||||
jmp .locret ;now really finished
|
||||
;-------------------------------------------------------------------------------
|
||||
;or not finished yet. Branch according to a row number (see documentation)
|
||||
.decode_z80_main_stage_next_third:
|
||||
sub bh,7
|
||||
sub edi,256*(8-1)
|
||||
jmp .decode_z80_main_stage_main_loop
|
||||
|
||||
.decode_z80_main_stage_image_not_finished:
|
||||
;next row
|
||||
add bh,8 ;refer to documentation
|
||||
add edi,256*(8-1)
|
||||
|
||||
;if finished row is 63 or 127 then we process next third of the image
|
||||
cmp bh,63+8
|
||||
je .decode_z80_main_stage_next_third
|
||||
cmp bh,127+8
|
||||
je .decode_z80_main_stage_next_third
|
||||
|
||||
cmp bh,56+8 ;if finished row in [56;63) or [120;127) or [184;191)
|
||||
jb .decode_z80_main_stage_main_loop
|
||||
cmp bh,63+8
|
||||
jb .4
|
||||
cmp bh,120+8
|
||||
jb .decode_z80_main_stage_main_loop
|
||||
cmp bh,127+8
|
||||
jb .4
|
||||
cmp bh,184+8
|
||||
jb .decode_z80_main_stage_main_loop
|
||||
;note that if we are here then bh is < 191 (see label .2) but >= 184+8
|
||||
.4:
|
||||
;and if we here then bh is in [56;63) or [120;127) or [184;191)
|
||||
sub bh,(8+56-1)
|
||||
sub edi,256*(8+56-1)
|
||||
sub edx,z80.AttrString*8
|
||||
jmp .decode_z80_main_stage_main_loop
|
||||
img.decode.z80.locret:
|
||||
popad
|
||||
ret
|
||||
img.decode.z80.failed:
|
||||
stdcall img.destroy,[frame1]
|
||||
jmp img.decode.z80.locret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode.z80 _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in z80 screen format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _img = pointer to image ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to encoded data ;;
|
||||
;< _p_length = encoded data length ;;
|
||||
;;================================================================================================;;
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below are private procs you should never call directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below is private data you should never use directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
z80._._16color_palette:
|
||||
dd 0 ; black
|
||||
dd 0x000000b0 ; blue
|
||||
dd 0x00b00000 ; red
|
||||
dd 0x00b000b0 ; magenta
|
||||
dd 0x0000b000 ; green
|
||||
dd 0x0000b0b0 ; cyan
|
||||
dd 0x00b0b000 ; yellow
|
||||
dd 0x00b0b0b0 ; gray
|
||||
dd 0 ; black
|
||||
dd 0x000000ff ; light blue
|
||||
dd 0x00ff0000 ; light red
|
||||
dd 0x00ff00ff ; light magenta
|
||||
dd 0x0000ff00 ; light green
|
||||
dd 0x0000ffff ; light cyan
|
||||
dd 0x00ffff00 ; light yellow
|
||||
dd 0x00ffffff ; white
|
||||
;;================================================================================================;;
|
||||
;;//// z80.asm //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; References: ;;
|
||||
;; 1. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
|
||||
include 'z80.inc'
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.is.z80 _data, _length ;//////////////////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Determine if raw data could be decoded (is in z80 screen format) ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = false / true ;;
|
||||
;;================================================================================================;;
|
||||
xor eax,eax
|
||||
cmp [_length],6929
|
||||
setz al
|
||||
je @f
|
||||
cmp [_length],6912
|
||||
setz al
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.decode.z80 _data, _length, _options ;////////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Decode data into image if it contains correctly formed raw data in z80 screen format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _data = raw data as read from file/stream ;;
|
||||
;> _length = data length ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to image ;;
|
||||
;;================================================================================================;;
|
||||
;---------------------------------------------------------------------------------------------------
|
||||
;During the decoding:
|
||||
;bl - PixelLeft (this means how much pixels left to put in current string)
|
||||
;bh - CurrentString
|
||||
;High half of ebx - use DualStos (two frames per one pixel_write)
|
||||
;cl - PixelColorIndexInPalette
|
||||
;ch - BackgroundColorIndexInPalette
|
||||
;High half of ecx - blinking flag
|
||||
;edx - address of current attribute byte
|
||||
;---------------------------------------------------------------------------------------------------
|
||||
locals
|
||||
frame1 dd ?
|
||||
OffsetIn2ndFrame dd ?
|
||||
endl
|
||||
xor eax,eax
|
||||
pushad
|
||||
cld ;paranoia
|
||||
stdcall img.create,256,192,Image.bpp8i
|
||||
test eax,eax
|
||||
jz img.decode.z80.locret ;test if allocation failed
|
||||
mov [frame1],eax
|
||||
mov esi,z80._._16color_palette
|
||||
mov ecx,16
|
||||
mov edi,[eax+Image.Palette]
|
||||
rep movsd ;write palette for the first frame
|
||||
mov esi,[_data]
|
||||
cmp [_length],6929
|
||||
jne @f
|
||||
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
|
||||
;if no - we'll produce statical single image
|
||||
mov ecx,768
|
||||
lea edx,[esi+6912-768];edx points to attribute area
|
||||
xor ebx,ebx ;begin from <0,0> (for further decoding)
|
||||
@@:
|
||||
test byte[edx+ecx-1],z80.BlinkFlag ;such addressing is a good optimisation
|
||||
;(as I hope), edx is unchanged
|
||||
jnz .decode_z80_with_blinking
|
||||
loop @b
|
||||
.decode_z80_without_blinking:
|
||||
jmp .decode_z80_main_stage
|
||||
|
||||
.decode_z80_with_blinking:
|
||||
or ebx,0xFFFF0000 ;use DualStos
|
||||
mov ecx,eax ;eax still points to the first frame
|
||||
stdcall img.create,256,192,Image.bpp8i
|
||||
test eax,eax
|
||||
jz img.decode.z80.failed
|
||||
mov [eax+Image.Previous],ecx
|
||||
mov [ecx+Image.Next],eax
|
||||
mov esi,z80._._16color_palette
|
||||
mov ecx,16
|
||||
mov edi,[eax+Image.Palette]
|
||||
rep movsd ;write palette for the second frame
|
||||
mov eax,[eax+Image.Data]
|
||||
mov [OffsetIn2ndFrame],eax
|
||||
;-------------------------------------------------------------------------------
|
||||
.decode_z80_main_stage:
|
||||
;2nd stage - convert z80 screen to 8bpp image with palette
|
||||
.decode_z80_main_stage_main_loop:
|
||||
test bl,7
|
||||
jnz .decode_z80_main_stage_put_now
|
||||
|
||||
._z80_update_attributes:
|
||||
movsx ecx,byte[edx] ;note that BlinkFlag is the highest bit in attribute
|
||||
;byte, so ecx's highest bit is set automatically
|
||||
shl ecx,5
|
||||
shr cl,5
|
||||
and ch,0xF
|
||||
test ch,1000b
|
||||
jz @f
|
||||
or ecx,1000b ;it has the same size with 'or cl,1000b' but could be faster
|
||||
@@:
|
||||
inc edx
|
||||
|
||||
lodsb
|
||||
mov ah,al
|
||||
|
||||
.decode_z80_main_stage_put_now:
|
||||
shl ah,1
|
||||
;-------------------------------------------------------------------------------
|
||||
._z80_put_pixel:
|
||||
;In: CF - put pixel with color CL, !CF - pixel with color CH
|
||||
;High parts of ebx and ecx - as described above
|
||||
mov al,cl ;'mov' doesn't affect flags
|
||||
jc @f
|
||||
mov al,ch
|
||||
@@:
|
||||
stosb ;'stosb' doesn't affect flags
|
||||
|
||||
test ebx,ebx
|
||||
jns @f
|
||||
test ecx,ecx
|
||||
jns .1
|
||||
mov al,ch
|
||||
.1:
|
||||
xchg [OffsetIn2ndFrame],edi
|
||||
stosb
|
||||
xchg [OffsetIn2ndFrame],edi
|
||||
@@:
|
||||
inc bl ;next pixel
|
||||
jz .decode_z80_main_stage_row_finished
|
||||
jmp .decode_z80_main_stage_main_loop
|
||||
;-------------------------------------------------------------------------------
|
||||
.decode_z80_main_stage_row_finished:
|
||||
cmp bh,191 ;is image finished?
|
||||
jb .decode_z80_main_stage_image_not_finished ;no.
|
||||
.decode_z80_finish:
|
||||
jmp .locret ;now really finished
|
||||
;-------------------------------------------------------------------------------
|
||||
;or not finished yet. Branch according to a row number (see documentation)
|
||||
.decode_z80_main_stage_next_third:
|
||||
sub bh,7
|
||||
sub edi,256*(8-1)
|
||||
jmp .decode_z80_main_stage_main_loop
|
||||
|
||||
.decode_z80_main_stage_image_not_finished:
|
||||
;next row
|
||||
add bh,8 ;refer to documentation
|
||||
add edi,256*(8-1)
|
||||
|
||||
;if finished row is 63 or 127 then we process next third of the image
|
||||
cmp bh,63+8
|
||||
je .decode_z80_main_stage_next_third
|
||||
cmp bh,127+8
|
||||
je .decode_z80_main_stage_next_third
|
||||
|
||||
cmp bh,56+8 ;if finished row in [56;63) or [120;127) or [184;191)
|
||||
jb .decode_z80_main_stage_main_loop
|
||||
cmp bh,63+8
|
||||
jb .4
|
||||
cmp bh,120+8
|
||||
jb .decode_z80_main_stage_main_loop
|
||||
cmp bh,127+8
|
||||
jb .4
|
||||
cmp bh,184+8
|
||||
jb .decode_z80_main_stage_main_loop
|
||||
;note that if we are here then bh is < 191 (see label .2) but >= 184+8
|
||||
.4:
|
||||
;and if we here then bh is in [56;63) or [120;127) or [184;191)
|
||||
sub bh,(8+56-1)
|
||||
sub edi,256*(8+56-1)
|
||||
sub edx,z80.AttrString*8
|
||||
jmp .decode_z80_main_stage_main_loop
|
||||
img.decode.z80.locret:
|
||||
popad
|
||||
ret
|
||||
img.decode.z80.failed:
|
||||
stdcall img.destroy,[frame1]
|
||||
jmp img.decode.z80.locret
|
||||
endp
|
||||
|
||||
;;================================================================================================;;
|
||||
proc img.encode.z80 _img, _p_length, _options ;///////////////////////////////////////////////////;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;? Encode image into raw data in z80 screen format ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;> _img = pointer to image ;;
|
||||
;;------------------------------------------------------------------------------------------------;;
|
||||
;< eax = 0 (error) or pointer to encoded data ;;
|
||||
;< _p_length = encoded data length ;;
|
||||
;;================================================================================================;;
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below are private procs you should never call directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;! Below is private data you should never use directly from your code ;;
|
||||
;;================================================================================================;;
|
||||
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
z80._._16color_palette:
|
||||
dd 0 ; black
|
||||
dd 0x000000b0 ; blue
|
||||
dd 0x00b00000 ; red
|
||||
dd 0x00b000b0 ; magenta
|
||||
dd 0x0000b000 ; green
|
||||
dd 0x0000b0b0 ; cyan
|
||||
dd 0x00b0b000 ; yellow
|
||||
dd 0x00b0b0b0 ; gray
|
||||
dd 0 ; black
|
||||
dd 0x000000ff ; light blue
|
||||
dd 0x00ff0000 ; light red
|
||||
dd 0x00ff00ff ; light magenta
|
||||
dd 0x0000ff00 ; light green
|
||||
dd 0x0000ffff ; light cyan
|
||||
dd 0x00ffff00 ; light yellow
|
||||
dd 0x00ffffff ; white
|
||||
|
@ -1,23 +1,23 @@
|
||||
;;================================================================================================;;
|
||||
;;//// z80.inc //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
z80.PixColor equ 000111b
|
||||
z80.BgrColor equ 111000b
|
||||
z80.BrightFlag equ (1 shl 6)
|
||||
z80.BlinkFlag equ (1 shl 7)
|
||||
;;================================================================================================;;
|
||||
;;//// z80.inc //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;;
|
||||
;;================================================================================================;;
|
||||
;; ;;
|
||||
;; 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/>. ;;
|
||||
;; ;;
|
||||
;;================================================================================================;;
|
||||
z80.PixColor equ 000111b
|
||||
z80.BgrColor equ 111000b
|
||||
z80.BrightFlag equ (1 shl 6)
|
||||
z80.BlinkFlag equ (1 shl 7)
|
||||
z80.AttrString equ 32
|
Loading…
Reference in New Issue
Block a user