网站导航网学 原创论文 原创专题 网站设计 最新系统 原创论文 论文降重 发表论文 论文发表 UI设计定制 论文答辩PPT格式排版 期刊发表 论文专题
返回网学首页
网学原创论文
最新论文 推荐专题 热门论文 论文专题
当前位置: 网学 > 设计资源 > 实用代码片段 > 正文

收藏的一些实用代码

论文降重修改服务、格式排版等 获取论文 论文降重及排版 论文发表 相关服务

  取bmp图片的宽与高

  // Width and height of a picture inside a BMP file

  int job

  blob b

  ulong width, height

  job = FileOpen( "filename.bmp", StreamMode!, Read! )

  FileRead( job, b )

  width = Long( Integer( BlobMid( b, 19, 2 ) ), &

  Integer( BlobMid( b, 21, 2) ) )

  height = Long( Integer( BlobMid( b, 23, 2 ) ), &

  Integer( BlobMid( b, 25, 2) ) )

  FileClose( job )

  得到极大的随机数

  //////////////////////////////////////////////////////////////////////////

  // Function: f_BigRand

  //

  // Description:

  // This function uses 2 calls to Rand to generate Random numbers for large

  // ranges. It breaks the range into blocks of 32767 (max range for

  // RAND function)

  // The limit of the function is 32767 blocks of 32767.

  // It calls RAND to first determine which block, then calls RAND again to

  // determine the number in the

  // selected block. To ensure even probability over the range where

  // there are multiple blocks,

  // the same sub range is used for each block.

  //

  // Argument al_range

  // The upper limit of the range of random numbers you want returned.

  // The lower limit is always 1. The maximum value for the argument is

  // 1,073,676,289 or 32767*32767.

  //

  // Returns

  // A random number in the range 1 to al_range inclusive.

  // Or 0 if max range exceeded.

  //

  // Author: David Dennis

  //////////////////////////////////////////////////////////////////////////

  //

  // Revision History

  //

  // -----------------------------------------------------------------------

  // VERSION CHANGE ID WHO WHEN WHAT/WHY

  // -----------------------------------------------------------------------

  // 6.30 8/4/00 Initial version.

  //////////////////////////////////////////////////////////////////////////

  Long ll_Offset, ll_Return

  Integer li_Range, li_Blocks

  // Block size is set to 32767 as this is the maximum range

  // the RAND function can handle

  Integer li_BlockSize = 32767

  IF al_range > 1073676289 THEN

  //Range is too big

  Return 0

  END IF

  //Determine The number of blocks

  li_Blocks = Truncate(al_range/li_BlockSize,0)

  //Add an extra block to accommodate any remainder

  IF Mod(al_range, li_BlockSize) > 0 THEN

  li_Blocks = li_Blocks + 1

  END IF

  // Improve efficiency for ranges less than Block Size

  // where there is only one block

  IF al_range < li_BlockSize THEN

  li_Range = al_range

  ELSE

  li_Range = li_BlockSize

  END IF

  ll_Return = 0

  // Loop until the value is in range.

  // If the value is not in range, calculate the

  // Offset again to ensure even probability

  DO UNTIL (ll_Return > 0) And (ll_Return <= al_Range)

  // Calculate a Random Offset using the number

  // of blocks as the range.

  // Offsets will range from [0 to

设为首页 | 加入收藏 | 网学首页 | 原创论文 | 计算机原创
版权所有 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2020 myeducs.Cn www.myeducs.Cn All Rights Reserved 湘ICP备09003080号 常年法律顾问:王律师