Programming and animation
Programming and animation ideas, articles, tutors, scripts, plugins in the 3d-
SMTP send
Posted on 13 June 2010 Neill No commentsA good example of sending mail is here - https://forum.antichat.ru/printthread.php?t=44490
Programming C++, Delphi, smtp, Tips, Win32
If you need a port to C + +, write to me.
P.S. Practice has shown that the service mail.ru better not to deal with. Half day caught cause loss of messages such as “mailbox does not exist”, while the same yandex sent no questions asked. -
Моя первая публикация
Posted on 26 February 2010 Neill No commentsThis article is not avaliable in english.
Недавно нашел у себя на компьютере весьма памятный мне материал – текст брошюры, которая продавалась в моем городе на рынке в книжной лавке. Это был октябрь 2000 года и мне тогда было 14 лет отроду.
Материал был написан на основе своего опыта работы с библиотекой OpenGL и разработкой проекта “Автомобиль в движении”. Как это всё было тогда наивно, но по своему загадочно и величественно на то время. В общем это было начало начал так сказать.
Graphics, Programming Delphi, OpenGL -
uMySQL for Delphi 2009 (Unicode)
Posted on 9 October 2009 Neill No comments
I present to you a library uMySQL. This is a small library for working with mySQL from Cristian Nicola. Unfortunately, the last update date of this very useful library – 2002. I adapted it for Unicode, to be able to use in modern versions of Delphi (2009, 2010, etc.).
In my version you can work only under Windows and without SSL.
Programming Delphi, mySQL -
Automate Delphi code documentation
Posted on 12 August 2009 Neill No comments
I Recently discovered a developing project PasDoc to generate documentaton for Delphi code – similar to doxygen. I have shared the link to the project, may be It will be useful to someone.
Project website – here
Programming Delphi, overview, Tool -
Delphi inline function
Posted on 25 June 2009 Neill No commentsStarting with the 2005 version of Delphi, it is possible to create inline functions, they significantly increase the speed of the code, due to the fact that do not generate a call of this function, but simply copy code to executing place. In so doing, excludes the steps associated with the allocation of function memory and the local variables, return values, etc. Instead of lines 10-15 is 3-5 lines of code for small functions for each execution point.
Programming Delphi -
TGA. image file format
Posted on 12 February 2009 Neill No commentsФормат хранения растровых изображений. Представлен в нескольких вариантах, среди которых самый простой – хранения битовой маски без сжатия, и чуть более сложных – использование алгоритма сжатия LZW.
Самый простой вариант TGA
Данный вариант формата бывает очень уместен, когда требуется сохранить, например, скриншот экрана. Нам достаточно в этом случае считать с нарисованного очередного кадра битовый массив определенного размера и его же сохранить в файл, при этом только составив заголовок TGA в начало файла для возможности дальнейшего чтения в любом подручном растровом редакторе. Согласитесь, что такой подход манит своей простотой.
Далее код будет представлен на Delphi (Object Pascal).
TGA без сжатия
Заголовок следующий
TTGAHEADER = packed record
tfType : Byte;
tfColorMapType : Byte;
tfImageType : Byte;
tfColorMapSpec : Array[0..4] of Byte;
tfOrigX : Array [0..1] of Byte;
tfOrigY : Array [0..1] of Byte;
tfWidth : Array [0..1] of Byte;
tfHeight : Array [0..1] of Byte;
tfBpp : Byte;
tfImageDes : Byte;
end;
Запись содержимого tga файла следующая:
1. обнуляем все параметры заголовка (первоначально)
ZeroMemory(@tgaHeader, SizeOf(tgaHeader));
2. заполняем по нашему усмотрению некоторые поля в информацией о растре
// Fill the structure with info for the image to be saved
tgaHeader.tfImageType := TGA_RGB;
tgaHeader.tfWidth[0] := Width mod 256;
tgaHeader.tfWidth[1] := Width div 256;
tgaHeader.tfHeight[0] := Height mod 256;
tgaHeader.tfHeight[1] := Height div 256;
tgaHeader.tfBpp := 32;
где TGA_RGB равно 2.
3. записываем заголовок
// Write the header to disk
bytesWritten := fileStream.Write( tgaHeader, sizeof(tgaHeader) );
if bytesWritten <> SizeOf(tgaHeader) then begin
Result := False;
Exit;
end;
4. меняем местами два цветовых канала (красный и синий)
// Switch the red and blue channels (from RGB to BGR)
SwapRB();
5. рассчитываем длину битового массива (включая альфа канал)
// Calculate number of bytes in image
length := Width*Height*4;
6. записываем битовый массив после заголовка
// Save the image contents to file
bytesWritten := fileStream.Write( rgbBits^, length );
if bytesWritten <> length then begin
Result := False;
Exit;
end;
Такова последовательность записи самого простого случая для tga формата.
Берем скриншот
Теперь пару слов о скриншотах ОГЛ экрана.
1. Получаем массив с текущими параметрами видового окна
glGetIntegerv(GL_VIEWPORT, @viewport);
2. устанавливаем информацию для растрового изображения
Width := viewport[2];
Height := viewport[3];
ColorDepth := 32;
3. Выделяем память под битовый массив в соответствии с размером окна (включая альфа канал)
GetMem(rgbBits, Width*Height*4);
4. Требуем завершить все команды рисования ОГЛ
glFinish();
5. устанавливаем режим выравнивания пикселей
glPixelStorei(GL_PACK_ALIGNMENT, 4);
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glPixelStorei(GL_PACK_SKIP_ROWS, 0);
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
6. читаем содержимое буфера кадра в битовый массив (включая альфа канал)
glReadPixels(0, 16, viewport[2], viewport[3], GL_RGBA, GL_UNSIGNED_BYTE, rgbBits);
7. теперь остается только прочитанное сохранить на диск в определенный растровый формат файла.
Programming Delphi, OpenGL, TGA


English
Russian
Recent Comments