News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Random Graphics Generator

Started by Bieb, February 27, 2005, 01:40:27 AM

Previous topic - Next topic

Ramon Sala

Excellent Gene! Your screen capture program is really good. Thank you.

Ramon
Greetings from Catalonia

Bieb

That's going to help a lot.  Thanks!

pbrennick

Bieb,
No problem, this, and any other code I make, can be preely used and/or modified any way you see fit.  I don't require a mention or any other restrictions; but a mention is sometimes nice.
Paul


Bieb

I'll be sure to put you in the credits.

Farabi

Great. I like it. But I cannot run it. Where is the exe file? And how to rotate arround X Y and Z axis?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Bieb

#20
Okay, now I'm at that really annoying stage where the program is so close to completion that you can almost smell it, but there are just a few annoying bugs in your way.  The code I've uploaded has rudimentary bitmap saving capabilities, but with two problems.  I decided that I didn't have time to thoroughly learn how to deal with bitmap headers, so I ended up just making a 24 bit bitmap in paint with the same dimensions as mine and stealing it's headers.  Then I just write the color data after them.  Anyways, I end up with two big problems.  The first is that the process of creating the bitmap takes a few seconds, and if another window comes in front of the edit control during that time, it's contents will end up in the bitmap file.  The second is that the bitmap files it generates don't seem quite right.  They look just fine if you open them up in paint, but if you open it in Windows Picture and Fax Viewer, or if Windows tries to make a preview of it, it just comes up with a little text string that says "drawing failed".

This is the bitmap saving loop itself

.data
JackedHeader DB 42H, 4DH, 0F6H, 76H, 8H, 0, 0, 0, 0, 0, 36H, 0, 0, 0, 28H, 0, 0, 0, 0ACH, 01H, 0, 0 , 0B0H, 01H, 0, 0, 01H, 0, \
18H, 0, 0, 0, 0, 0, 76H, 08H
DB 17 Dup(0)
FilePath DB "C:\RGG.bmp", 0

...

SaveBitmap Proc Private
Local StaticFileHDC:DWord
Local GarbageDW:DWord
Local FileHandle:DWord
Local LoopTemp1:DWord
Local LoopTemp2:DWord
Local RGBholder:DWord
Local AdressHolder:DWord
Invoke GetDC, StaticHandle
Mov StaticFileHDC, Eax
Invoke CreateFile, Addr FilePath, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
Mov FileHandle, Eax
Invoke WriteFile, FileHandle, Addr JackedHeader, 35H, Addr GarbageDW, NULL
Mov LoopTemp1, 432
Loop1:
.If LoopTemp1 == 0
Jmp ExitLoop
.EndIf
Mov LoopTemp2, 0
Loop2:
Invoke GetPixel, StaticFileHDC, LoopTemp2, LoopTemp1
Mov RGBholder, Eax
Lea Eax, RGBholder
Add Eax, 0
Mov AdressHolder, Eax
Mov AdressHolder, Eax
Invoke WriteFile, FileHandle, AdressHolder, 1, Addr GarbageDW, NULL
Lea Eax, RGBholder
Add Eax, 2
Mov AdressHolder, Eax
Invoke WriteFile, FileHandle, AdressHolder, 1, Addr GarbageDW, NULL
Lea Eax, RGBholder
Add Eax, 1
Mov AdressHolder, Eax
Invoke WriteFile, FileHandle, AdressHolder, 1, Addr GarbageDW, NULL
Inc LoopTemp2
.If LoopTemp2 == 428
Dec LoopTemp1
Jmp Loop1
.Else
Jmp Loop2
.EndIf
ExitLoop:
Invoke ReleaseDC, StaticHandle, StaticFileHDC
Invoke CloseHandle, FileHandle
Ret
SaveBitmap EndP

[attachment deleted by admin]

Bieb

Quote from: Farabi on March 12, 2005, 02:18:49 AM
Great. I like it. But I cannot run it. Where is the exe file? And how to rotate arround X Y and Z axis?

Paul's screen capture or the random graphics generator?  The random graphics generator is supposed to be completely uncontrollable, so you can't rotate it.  It doesn't even have a Z axis, since there isn't any 3D rendering going on.  Everything you see is 2D vector graphics.  If it's Paul's program you're talking about, the EXE is right in the ZIP file.  In mine, I've only included source code, since it isn't a general release yet.

Bieb

Scratch the second problem.  Problem is that I was making the headers one byte too short.  Now that I've got that taken care of, how shall I deal with the problem of interference?  Here's a revised SaveBitmap proc.


SaveBitmap Proc Private
Local StaticFileHDC:DWord
Local GarbageDW:DWord
Local FileHandle:DWord
Local LoopTemp1:DWord
Local LoopTemp2:DWord
Local RGBholder:DWord
Local AdressHolder:DWord
Invoke GetDC, StaticHandle
Mov StaticFileHDC, Eax
Invoke CreateFile, Addr FilePath, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
Mov FileHandle, Eax
Invoke WriteFile, FileHandle, Addr JackedHeader, 36H, Addr GarbageDW, NULL
Mov LoopTemp1, 432
Loop1:
.If LoopTemp1 == 0
Jmp ExitLoop
.EndIf
Mov LoopTemp2, 0
Loop2:
Invoke GetPixel, StaticFileHDC, LoopTemp2, LoopTemp1
Mov RGBholder, Eax
Lea Eax, RGBholder
Add Eax, 2
Mov AdressHolder, Eax
Mov AdressHolder, Eax
Invoke WriteFile, FileHandle, AdressHolder, 1, Addr GarbageDW, NULL
Lea Eax, RGBholder
Add Eax, 1
Mov AdressHolder, Eax
Invoke WriteFile, FileHandle, AdressHolder, 1, Addr GarbageDW, NULL
Lea Eax, RGBholder
Add Eax, 0
Mov AdressHolder, Eax
Invoke WriteFile, FileHandle, AdressHolder, 1, Addr GarbageDW, NULL
Inc LoopTemp2
.If LoopTemp2 == 428
Dec LoopTemp1
Jmp Loop1
.Else
Jmp Loop2
.EndIf
ExitLoop:
Invoke ReleaseDC, StaticHandle, StaticFileHDC
Invoke CloseHandle, FileHandle
Ret
SaveBitmap EndP

Bieb

All the problems are solved, and I've finally finished version 1.0 (http://filehost.bieberworks.net/RGG.zip).  Now I'm working on an animated version, for a school technology fair.

OceanJeff32

I might have downloaded the wrong thing, but I didn't get an executable or any .asm code...

I got a c/c++ header file, something called window1.ecw, and two icons in other directories.

How should I start in making your random graphics generator...

??

later,

jeff c
:dazzled:
Any good programmer knows, every large and/or small job, is equally large, to the programmer!

Ramon Sala

Hi OceanJeff32,

The RGG.zip file contains an Easy Code project. The .ecw file is a window file which contains the window properties and the assembly code. To load and build the project, you need the Easy Code IDE which is available for free at this forum. See the Get the last version of Easy Code here topic.

Regards,

Ramon
Greetings from Catalonia

Bieb

Here's a link to the executable, if you want it:
http://filehost.bieberworks.net/RGG.exe
And here's the animated version (warning, it's a major CPU hog):
http://filehost.bieberworks.net/RGGa.exe

I never did release the source code for the animated version.  Does anyone want it?

Farabi

Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"