Ответить на комментарий

Алгоритм Grayscale на Delphi

> p:=ScanLine[Height-1];
> q:=ScanLine[0];
> if cardinal(p)>cardinal(q) then p:=q;

Возвращаемое значение указателя может зависеть от внутренней реализации ScanLine. Даже если просто вызвать ScanLine[0] 2 раза подряд, может получиться 2 разных адреса (возвращается не адрес внутреннего сплошного буфера bmp, а адрес копии заказанной строки).
Remy Lebeau:
The ScanLine property itself frees and recreates the internal bitmap data everytime you access it, thus you get a different memory address each time you access the ScanLine property, even when using the same index each time. This is because TBitmap is reference-counted internally, so doing something that can potentially alter the internal bitmap data, such as altering the bitmaps of the ScanLine data, can effect multiple TBitmap instances. So, TBitmap first clones the internal data before then allowing direct access to the data.

Конечно, в вашей программе адреса получаются и сравниваются до модификации, так что вроде это работает. Но однажды это может перестать работать. Для определения расположения строк в bmp, существует BITMAPINFOHEADER и его поле biHeight (см. MSDN):

Specifies the height of the bitmap, in pixels. If biHeight is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. If biHeight is negative, the bitmap is a top-down DIB and its origin is the upper-left corner.

Вообще, насколько я знаю, обращение к bmp как к сплошному массиву, нигде не документировано. Теоретически возможно, что данные могут быть разбросаны в памяти.

Ответить

  • Адреса страниц и электронной почты автоматически преобразуются в ссылки.
  • Доступны HTML теги: <h1> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Строки и параграфы переносятся автоматически.
  • You can enable syntax highlighting of source code with the following tags: <pre>, <code>, <asm>, <c>, <cpp>, <delphi>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>, <mytext>. Beside the tag style "<foo>" it is also possible to use "[foo]".

Подробнее о форматировании

CAPTCHA
Ведите текст с изображения. (вводить еще раз после предпросмотра а то не добавится комментарий)
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.