2010-11-20 17:27 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* src/rtl/sha1.c
    * Settling back to original version of some lines.

  - contrib/hbgd/tests/tpoly.hbp
  - contrib/hbgd/tests/tpolyc.c
    - Using hbct functions with same name, so this is not needed.

  * contrib/hbgd/tests/tpoly.prg
    * Applied patch from Tamas.
    * Since final patch didn't apply I went on to rename static 
      vars to have s_ prefix.

  * contrib/hbgd/tests/gdtest.prg
  * contrib/hbgd/tests/barms.prg
  * contrib/hbgd/tests/bartest.prg
  * contrib/hbgd/tests/gdtestcl.prg
  * contrib/hbgd/tests/tostring.prg
  * contrib/hbgd/tests/animgif.prg
  * contrib/hbgd/tests/testdpi.prg
  * contrib/hbgd/tests/test.prg
  * contrib/hbgd/tests/counter.prg
  * contrib/hbgd/tests/antialia.prg
    * Using hb_ps(). Patch from Tamas.
This commit is contained in:
Viktor Szakats
2010-11-20 16:28:13 +00:00
parent 166131f652
commit 82c2c97a65
15 changed files with 102 additions and 90 deletions

View File

@@ -16,6 +16,31 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-11-20 17:27 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* src/rtl/sha1.c
* Settling back to original version of some lines.
- contrib/hbgd/tests/tpoly.hbp
- contrib/hbgd/tests/tpolyc.c
- Using hbct functions with same name, so this is not needed.
* contrib/hbgd/tests/tpoly.prg
* Applied patch from Tamas.
* Since final patch didn't apply I went on to rename static
vars to have s_ prefix.
* contrib/hbgd/tests/gdtest.prg
* contrib/hbgd/tests/barms.prg
* contrib/hbgd/tests/bartest.prg
* contrib/hbgd/tests/gdtestcl.prg
* contrib/hbgd/tests/tostring.prg
* contrib/hbgd/tests/animgif.prg
* contrib/hbgd/tests/testdpi.prg
* contrib/hbgd/tests/test.prg
* contrib/hbgd/tests/counter.prg
* contrib/hbgd/tests/antialia.prg
* Using hb_ps(). Patch from Tamas.
2010-11-20 13:22 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rtl/sha1.c
* cleaned casting to not drop canst attribute

View File

@@ -13,8 +13,8 @@
#include "gd.ch"
#include "common.ch"
#define IMAGES_IN "imgs_in/"
#define IMAGES_OUT "imgs_out/"
#define IMAGES_IN "imgs_in" + hb_ps()
#define IMAGES_OUT "imgs_out" + hb_ps()
PROCEDURE Main()

View File

@@ -11,8 +11,8 @@
#include "gd.ch"
#include "common.ch"
#define IMAGES_IN "imgs_in/"
#define IMAGES_OUT "imgs_out/"
#define IMAGES_IN "imgs_in" + hb_ps()
#define IMAGES_OUT "imgs_out" + hb_ps()
PROCEDURE Main()

View File

@@ -2,7 +2,7 @@
* $Id$
*/
#define IMAGES_OUT "imgs_out/"
#define IMAGES_OUT "imgs_out" + hb_ps()
Function Main()

View File

@@ -2,7 +2,7 @@
* $Id$
*/
#define IMAGES_OUT "imgs_out/"
#define IMAGES_OUT "imgs_out" + hb_ps()
Function Main()

View File

@@ -17,8 +17,8 @@
/* Some digits images from:
http://www.digitmania.holowww.com/all.html */
#define IMAGES_IN "digits/"
#define IMAGES_OUT "imgs_out/"
#define IMAGES_IN "digits" + hb_ps()
#define IMAGES_OUT "imgs_out" + hb_ps()
#define DISPLAY_NUM 10

View File

@@ -11,8 +11,8 @@
#include "gd.ch"
#include "common.ch"
#define IMAGES_IN "imgs_in/"
#define IMAGES_OUT "imgs_out/"
#define IMAGES_IN "imgs_in" + hb_ps()
#define IMAGES_OUT "imgs_out" + hb_ps()
PROCEDURE Main()

View File

@@ -11,8 +11,8 @@
#include "gd.ch"
#include "common.ch"
#define IMAGES_IN "imgs_in/"
#define IMAGES_OUT "imgs_out/"
#define IMAGES_IN "imgs_in" + hb_ps()
#define IMAGES_OUT "imgs_out" + hb_ps()
PROCEDURE Main()

View File

@@ -2,7 +2,7 @@
* $Id$
*/
#define IMAGES_OUT "imgs_out/"
#define IMAGES_OUT "imgs_out" + hb_ps()
PROCEDURE Main()

View File

@@ -12,8 +12,8 @@
#include "gd.ch"
#include "common.ch"
#define IMAGES_IN "imgs_in/"
#define IMAGES_OUT "imgs_out/"
#define IMAGES_IN "imgs_in" + hb_ps()
#define IMAGES_OUT "imgs_out" + hb_ps()
PROCEDURE Main()

View File

@@ -12,8 +12,8 @@
#include "gd.ch"
#include "common.ch"
#define IMAGES_IN "imgs_in/"
#define IMAGES_OUT "imgs_out/"
#define IMAGES_IN "imgs_in" + hb_ps()
#define IMAGES_OUT "imgs_out" + hb_ps()
PROCEDURE Main()

View File

@@ -1,8 +0,0 @@
#
# $Id$
#
hbmk.hbm
tpoly.prg
tpolyc.c

View File

@@ -1,76 +1,98 @@
/*
/*
* $Id$
*/
/*
* Not Quite a Koch Flake -- but good for testing gdImage*Polygon()
* Koch Flake -- for testing gdImage*Polygon()
*/
#include "gd.ch"
#include "simpleio.ch"
REQUEST HB_GT_CGI_DEFAULT
#command TurnRight( <x> ) => nAngle += M_PI / 3 * <x>
#command TurnLeft( <x> ) => nAngle -= M_PI / 3 * <x>
#define M_PI 3.14159265358979323846
#define IMAGES_OUT "imgs_out/"
#define IMAGES_OUT "imgs_out" + hb_ps()
STATIC aCoords
STATIC nSideLen
STATIC nAngle, nCoordX, nCoordY
STATIC s_aCoords
STATIC s_nSides, s_nSideLen
STATIC s_nAngle, s_nCoordX, s_nCoordY
PROCEDURE Main()
LOCAL nDepth, nSide
LOCAL gdImage, gdColor
nSideLen := 100
nDepth := 4
s_nSides := 3
s_nSideLen := 1500
nDepth := 7
nCoordX := 50
nCoordY := 50
aCoords := { { nCoordX, nCoordY } }
nAngle := 0
s_nCoordX := 200
s_nCoordY := 600
s_aCoords := { { s_nCoordX, s_nCoordY } }
s_nAngle := 0
FOR nSide := 1 TO 3
NQKochFlake( nDepth, nSideLen )
nAngle += M_PI * 2 / 3
/* Regular flake */
FOR nSide := 1 TO s_nSides
KochFlake( nDepth, s_nSideLen, .T. )
s_nAngle += M_PI * 2 / s_nSides
NEXT
NQKochFlake( nDepth, nSideLen )
/* Flake inside out */
FOR nSide := 1 TO s_nSides
KochFlake( nDepth, s_nSideLen, .F. )
s_nAngle += M_PI * 2 / s_nSides
NEXT
OutStd( hb_strFormat( "Drawing %d coordinate pairs%s", Len( aCoords ), hb_eol() ) )
OutStd( hb_strFormat( "Drawing %d vertices%s", Len( s_aCoords ), hb_eol() ) )
gdImage := gdImageCreate( 8200, 7115 )
gdImage := gdImageCreate( 1900, 2100 )
gdImageColorAllocate( gdImage, 0, 0, 0 )
gdColor := gdImageColorAllocate( gdImage, 255, 255, 255 )
gdImagePolygon( gdImage, aCoords, gdColor )
gdColor := gdImageColorAllocate( gdImage, 255, 255, 0 )
gdImagePolygon( gdImage, s_aCoords, gdColor )
gdImagePng( gdImage, IMAGES_OUT + "flake.png" )
gdImageDestroy( gdImage )
gdImage := gdImageCreate( 8200, 7115 )
gdImage := gdImageCreate( 1900, 2100 )
gdImageColorAllocate( gdImage, 0, 0, 0 )
gdColor := gdImageColorAllocate( gdImage, 255, 255, 255 )
gdImageOpenPolygon( gdImage, aCoords, gdColor )
gdColor := gdImageColorAllocate( gdImage, 255, 255, 0 )
gdImageOpenPolygon( gdImage, s_aCoords, gdColor )
gdImagePng( gdImage, IMAGES_OUT + "flakeo.png" )
gdImageDestroy( gdImage )
RETURN
PROCEDURE NQKochFlake( nDepth, nSideLen )
PROCEDURE KochFlake( nDepth, s_nSideLen, lLeftFirst )
IF nDepth == 0
AAdd( aCoords, {;
nCoordX += Cos( nAngle ) * nSideLen,;
nCoordY += Sin( nAngle ) * nSideLen;
AAdd( s_aCoords, {;
s_nCoordX += Cos( s_nAngle ) * s_nSideLen,;
s_nCoordY += Sin( s_nAngle ) * s_nSideLen;
})
ELSE
NQKochFlake( nDepth - 1, nSideLen )
nAngle += M_PI / 3
NQKochFlake( nDepth - 1, nSideLen )
nAngle -= M_PI * 2 / 3
NQKochFlake( nDepth - 1, nSideLen )
nAngle += M_PI / 3
NQKochFlake( nDepth - 1, nSideLen )
KochFlake( nDepth - 1, s_nSideLen / 3, lLeftFirst )
IF lLeftFirst
TurnLeft( 1 )
ELSE
TurnRight( 1 )
ENDIF
KochFlake( nDepth - 1, s_nSideLen / 3, lLeftFirst )
IF lLeftFirst
TurnRight( 2 )
ELSE
TurnLeft( 2 )
ENDIF
KochFlake( nDepth - 1, s_nSideLen / 3, lLeftFirst )
IF lLeftFirst
TurnLeft( 1 )
ELSE
TurnRight( 1 )
ENDIF
KochFlake( nDepth - 1, s_nSideLen / 3, lLeftFirst )
ENDIF
RETURN

View File

@@ -1,25 +0,0 @@
/*
* $Id$
*/
#include <math.h>
#include "hbapi.h"
#include "hbapierr.h"
#define WRAP( hbfunc, mfunc ) \
HB_FUNC( hbfunc ) \
{ \
if( HB_ISNUM( 1 ) ) \
{ \
double dArg, dResult; \
dArg = hb_parnd( 1 ); \
dResult = mfunc( dArg ); \
hb_retnd( dResult ); \
} \
else \
hb_errRT_BASE_SubstR( EG_ARG, 1097, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); \
}
WRAP( SIN, sin )
WRAP( COS, cos )

View File

@@ -148,16 +148,14 @@ void hb_SHA1_Update(SHA_CTX *context, const void *datav, unsigned int len) {
void hb_SHA1_Final(sha1_byte digest[SHA1_DIGEST_LENGTH], SHA_CTX *context) {
sha1_quadbyte i;
sha1_byte finalcount[8];
sha1_byte str1[ 1 ] = { '\x80' };
sha1_byte str2[ 1 ] = { '\0' };
for (i = 0; i < 8; i++) {
finalcount[i] = (sha1_byte)((context->count[(i >= 4 ? 0 : 1)]
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
}
hb_SHA1_Update(context, str1, 1);
hb_SHA1_Update(context, (const sha1_byte *)"\x80", 1);
while ((context->count[0] & 504) != 448) {
hb_SHA1_Update(context, str2, 1);
hb_SHA1_Update(context, (const sha1_byte *)"\0", 1);
}
/* Should cause a SHA1_Transform() */
hb_SHA1_Update(context, finalcount, 8);