123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074 |
- {
- Free Pascal port of the Hermes C library.
- Copyright (C) 2001-2003 Nikolay Nikolov ([email protected])
- Original C version by Christian Nentwich ([email protected])
- This library 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
- with the following modification:
- As a special exception, the copyright holders of this library give you
- permission to link this library with independent modules to produce an
- executable, regardless of the license terms of these independent modules,and
- to copy and distribute the resulting executable under terms of your choice,
- provided that you also meet, for each linked independent module, the terms
- and conditions of the license of that module. An independent module is a
- module which is not derived from or based on this library. If you modify
- this library, you may extend this exception to your version of the library,
- but you are not obligated to do so. If you do not wish to do so, delete this
- exception statement from your version.
- This library 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 this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- }
- {
- Generic format conversion routines for the HERMES library
- Copyright (c) 1998 Christian Nentwich ([email protected])
- This source code is licensed under the GNU LGPL
- Please refer to the file COPYING.LIB contained in the distribution for
- licensing conditions
- }
- procedure ConvertP_Generic32_Generic32(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- begin
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := PUint32(source)^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint32(dest)^ := r or g or b;
- Inc(source, 4);
- Inc(dest, 4);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic32_Generic24(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- d_ptr: PUint8;
- count: DWord;
- source, dest: PUint8;
- begin
- d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := PUint32(source)^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- s_pixel := r or g or b;
- (dest+0)^ := (d_ptr+0)^;
- (dest+1)^ := (d_ptr+1)^;
- (dest+2)^ := (d_ptr+2)^;
- Inc(source, 4);
- Inc(dest, 3);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic32_Generic16(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- begin
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width shr 1;
- if count <> 0 then
- repeat
- r := (((PUint32(source)^) shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := (((PUint32(source)^) shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := (((PUint32(source)^) shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- s_pixel := (r or g or b) shl DWORD_SMALLINT0_SHL;
- r := ((((PUint32(source)+1)^) shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((((PUint32(source)+1)^) shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((((PUint32(source)+1)^) shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- s_pixel := s_pixel or ((r or g or b) shl DWORD_SMALLINT1_SHL);
- PUint32(dest)^ := s_pixel;
- Inc(source, 8);
- Inc(dest, 4);
- Dec(count);
- until count = 0;
- { Trailing pixel }
- if (iface^.s_width and 1) <> 0 then
- begin
- r := (((PUint32(source)^) shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := (((PUint32(source)^) shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := (((PUint32(source)^) shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint16(dest)^ := r or g or b;
- Inc(dest, 2);
- Inc(source, 4);
- end;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic32_Generic8(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- begin
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := PUint32(source)^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- dest^ := r or g or b;
- Inc(source, 4);
- Inc(dest);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic24_Generic32(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- begin
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := (((source+R_24)^) shl 16) or
- (((source+G_24)^) shl 8) or
- ((source+B_24)^);
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint32(dest)^ := r or g or b;
- Inc(source, 3);
- Inc(dest, 4);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic24_Generic24(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- d_ptr: PUint8;
- count: DWord;
- source, dest: PUint8;
- begin
- d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := (((source+R_24)^) shl 16) or
- (((source+G_24)^) shl 8) or
- ((source+B_24)^);
- r := ((s_pixel shl iface^.info.r_left) shr iface^.info.r_right) and
- iface^.mask_r;
- g := ((s_pixel shl iface^.info.g_left) shr iface^.info.g_right) and
- iface^.mask_g;
- b := ((s_pixel shl iface^.info.b_left) shr iface^.info.b_right) and
- iface^.mask_b;
- s_pixel := r or g or b;
- (dest + 0)^ := (d_ptr + 0)^;
- (dest + 1)^ := (d_ptr + 1)^;
- (dest + 2)^ := (d_ptr + 2)^;
- Inc(source, 3);
- Inc(dest, 3);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic24_Generic16(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- begin
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := (((source+R_24)^) shl 16) or
- (((source+G_24)^) shl 8) or
- ((source+B_24)^);
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint16(dest)^ := r or g or b;
- Inc(source, 3);
- Inc(dest, 2);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic24_Generic8(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- begin
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := (((source+R_24)^) shl 16) or
- (((source+G_24)^) shl 8) or
- ((source+B_24)^);
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- dest^ := r or g or b;
- Inc(source, 3);
- Inc(dest);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic16_Generic32(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- begin
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := PUint16(source)^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint32(dest)^ := r or g or b;
- Inc(source, 2);
- Inc(dest, 4);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic16_Generic24(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- d_ptr: PUint8;
- count: DWord;
- source, dest: PUint8;
- begin
- d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := PUint16(source)^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- s_pixel := r or g or b;
- (dest + 0)^ := (d_ptr + 0)^;
- (dest + 1)^ := (d_ptr + 1)^;
- (dest + 2)^ := (d_ptr + 2)^;
- Inc(source, 2);
- Inc(dest, 3);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic16_Generic16(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- begin
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := PUint16(source)^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint16(dest)^ := r or g or b;
- Inc(source, 2);
- Inc(dest, 2);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic16_Generic8(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- begin
- source := iface^.s_pixels; dest := iface^.d_pixels;
- repeat
- count := iface^.s_width;
- repeat
- s_pixel := PUint16(source)^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- dest^ := r or g or b;
- Inc(source, 2);
- Inc(dest);
- Dec(count);
- until count = 0;
- Inc(source, iface^.s_add);
- Inc(dest, iface^.d_add);
- Dec(iface^.s_height);
- until iface^.s_height = 0;
- end;
- procedure ConvertP_Generic8_Generic32(iface: PHermesConverterInterface); cdecl;
- begin
- {todo}
- end;
- procedure ConvertP_Generic8_Generic24(iface: PHermesConverterInterface); cdecl;
- begin
- {todo}
- end;
- procedure ConvertP_Generic8_Generic16(iface: PHermesConverterInterface); cdecl;
- begin
- {todo}
- end;
- procedure ConvertP_Generic8_Generic8(iface: PHermesConverterInterface); cdecl;
- begin
- {todo}
- end;
- { -------------------------------------------------------------------------
- STRETCH CONVERTERS
- ------------------------------------------------------------------------- }
- procedure ConvertP_Generic32_Generic32_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- repeat
- s_pixel := (PUint32(source)+(x shr 16))^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint32(dest)^ := r or g or b;
- Inc(x, dx);
- Inc(dest, 4);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic32_Generic24_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- d_ptr: PUint8;
- count: DWord;
- source, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- repeat
- s_pixel := (PUint32(source)+(x shr 16))^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- s_pixel := r or g or b;
- (dest + 0)^ := (d_ptr + 0)^;
- (dest + 1)^ := (d_ptr + 1)^;
- (dest + 2)^ := (d_ptr + 2)^;
- Inc(x, dx);
- Inc(dest, 3);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic32_Generic16_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- repeat
- s_pixel := (PUint32(source)+(x shr 16))^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint16(dest)^ := r or g or b;
- Inc(x, dx);
- Inc(dest, 2);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic32_Generic8_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- repeat
- s_pixel := (PUint32(source)+(x shr 16))^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- dest^ := r or g or b;
- Inc(x, dx);
- Inc(dest);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic24_Generic32_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, src, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- src := source;
- repeat
- s_pixel := (((src+R_24)^) shl 16) or
- (((src+G_24)^) shl 8) or
- ((src+B_24)^);
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint32(dest)^ := r or g or b;
- Inc(x, dx);
- Inc(src, x shr 16);
- Inc(src, x shr 16);
- Inc(src, x shr 16);
- x := x and $FFFF;
- Inc(dest, 4);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic24_Generic24_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- d_ptr: PUint8;
- count: DWord;
- source, src, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- src := source;
- repeat
- s_pixel := (((src+R_24)^) shl 16) or
- (((src+G_24)^) shl 8) or
- ((src+B_24)^);
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- s_pixel := r or g or b;
- (dest + 0)^ := (d_ptr + 0)^;
- (dest + 1)^ := (d_ptr + 1)^;
- (dest + 2)^ := (d_ptr + 2)^;
- Inc(x, dx);
- Inc(src, x shr 16);
- Inc(src, x shr 16);
- Inc(src, x shr 16);
- x := x and $FFFF;
- Inc(dest, 3);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic24_Generic16_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, src, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- src := source;
- repeat
- s_pixel := (((src+R_24)^) shl 16) or
- (((src+G_24)^) shl 8) or
- ((src+B_24)^);
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint16(dest)^ := r or g or b;
- Inc(x, dx);
- Inc(src, x shr 16);
- Inc(src, x shr 16);
- Inc(src, x shr 16);
- x := x and $FFFF;
- Inc(dest, 2);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic24_Generic8_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, src, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- src := source;
- repeat
- s_pixel := (((src+R_24)^) shl 16) or
- (((src+G_24)^) shl 8) or
- ((src+B_24)^);
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- dest^ := r or g or b;
- Inc(x, dx);
- Inc(src, x shr 16);
- Inc(src, x shr 16);
- Inc(src, x shr 16);
- x := x and $FFFF;
- Inc(dest);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic16_Generic32_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- repeat
- s_pixel := (PUint16(source)+(x shr 16))^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint32(dest)^ := r or g or b;
- Inc(x, dx);
- Inc(dest, 4);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic16_Generic24_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- d_ptr: PUint8;
- count: DWord;
- source, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- repeat
- s_pixel := (PUint16(source)+(x shr 16))^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- s_pixel := r or g or b;
- (dest + 0)^ := (d_ptr + 0)^;
- (dest + 1)^ := (d_ptr + 1)^;
- (dest + 2)^ := (d_ptr + 2)^;
- Inc(x, dx);
- Inc(dest, 3);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic16_Generic16_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- repeat
- s_pixel := (PUint16(source)+(x shr 16))^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- PUint16(dest)^ := r or g or b;
- Inc(x, dx);
- Inc(dest, 2);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic16_Generic8_S(iface: PHermesConverterInterface); cdecl;
- var
- s_pixel, r, g, b: Uint32;
- count: DWord;
- source, dest: PUint8;
- dx, dy, x, y: DWord;
- begin
- source := iface^.s_pixels;
- dest := iface^.d_pixels;
- dy := (iface^.s_height shl 16) div iface^.d_height;
- dx := (iface^.s_width shl 16) div iface^.d_width;
- y := 0;
- repeat
- count := iface^.d_width;
- x := 0;
- repeat
- s_pixel := (PUint16(source)+(x shr 16))^;
- r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
- iface^.mask_r;
- g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
- iface^.mask_g;
- b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
- iface^.mask_b;
- dest^ := r or g or b;
- Inc(x, dx);
- Inc(dest);
- Dec(count);
- until count = 0;
- Inc(dest, iface^.d_add);
- Inc(y, dy);
- Inc(source, (y shr 16)*DWord(iface^.s_pitch));
- y := y and $ffff;
- Dec(iface^.d_height);
- until iface^.d_height = 0;
- end;
- procedure ConvertP_Generic8_Generic32_S(iface: PHermesConverterInterface); cdecl;
- begin
- {todo}
- end;
- procedure ConvertP_Generic8_Generic24_S(iface: PHermesConverterInterface); cdecl;
- begin
- {todo}
- end;
- procedure ConvertP_Generic8_Generic16_S(iface: PHermesConverterInterface); cdecl;
- begin
- {todo}
- end;
- procedure ConvertP_Generic8_Generic8_S(iface: PHermesConverterInterface); cdecl;
- begin
- {todo}
- end;
|