PDA

Click to See Complete Forum and Search --> : Sub PutPixel(x, y As Integer, color As Byte) --> how?


itay222
Dec 18th, 2000, 08:49 AM
hello.

i would like to be able to plot a pixel with a specified
color on the screen (or inside some kind of a box[?]).
oh yeah... it needs to be ***fast***.
never have i used directX or opengl or whatever (i have NT).

now come'on,
is it that difficult question?
(and while you reply, some help about changing video modes
would be most appreciated).

thanx.
-i.

kedaman
Dec 18th, 2000, 09:40 AM
What are you intending to do, DirectDraw is probably the fastest possible solution, if you don't want to depend on DirectX you can use SetpixelV api.

itay222
Dec 18th, 2000, 09:44 AM
i don't mind using directdraw,
just never have i done before.
i am not affraid also...
i just need to know how to get started :)

itay.

kedaman
Dec 18th, 2000, 03:51 PM
Before you do this you should learn the basics of DirectDraw, you can take a look at Fox DirectDraw demo on his homepage (theres a link on his signature) also you can search on this forum for more info.
The manipulations of the surfaces are a bit tricky, you need to lock them first with lock method. after all manipulations are done you can unlock it again for use.

Dim nullrect 'this rect is empty, and should stay
Dim Desc As DDSURFACEDESC2
Dim surface As DirectDrawSurface7 'this one needs to be initialized
surface.Lock nullrect, Desc, DDLOCK_WAIT, 0
surface.SetLockedPixel X, Y, color

surface.Unlock nullrect

The rect parameters is just for locking parts of a surface and you probably wont need to do that so by sending an empty rect it will select the whole surface.

itay222
Dec 19th, 2000, 02:42 AM
allow me to rephrase:

i would like to make a button on a form in visual basic.
on the event of button click,
i want the screen to go 320x200 256 colors.
then i will plot very *fast* pixel with all the colors
of the rainbow on the screen.
when [esc] is pressed, the vb form will return.

is that possible?
assume my knowledge of directdraw equals
your knowledge on writing demos in assembler.

itay.

kedaman
Dec 19th, 2000, 07:14 AM
Yes it's possible and easy too, i could send you a sample project of it if you want.

Jotaf98
Dec 20th, 2000, 05:15 PM
Hey, I've seen an example on direct memory access at http://www.ur.co.nz/ , it's much faster than DirectDraw's SetLockedPixel!

itay222
Dec 21st, 2000, 02:53 AM
hey,
great stuff there.
now, all i need to know is how to do it on
the entire screen.
but anyway, thanks for your reply!

itay.

Jotaf98
Dec 21st, 2000, 08:01 AM
You're welcome ;)

I think it's a demo on how to make fast translucency, but since you want a rainbow, you'd have to fill the palette with the rainbow's colors, then it would be easy to make the rest! If you need help on it, e-mail me or post here again.

You'll have to make another form with no border and maximized. There's a way of making your form stay on top of all others so you can ocupy the whole screen:



'Paste this into the form's declarations (top-most lines)

Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)

Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_SHOWWINDOW = &H40



'Use this code to make the form "Top-Most"

SetWindowPos Form1.hWnd, HWND_TOPMOST, Form1.Left / 15, _
Form1.Top / 15, Form1.Width / 15, _
Form1.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW



'Use this code to make the form back to normal

SetWindowPos Form1.hWnd, HWND_NOTOPMOST, Form1.Left / 15, _
Form1.Top / 15, Form1.Width / 15, _
Form1.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW



That should solve your problem! In the Form_Load event, make the form top-most and maximize it (by setting the WindowState property of the form to 2). In the Form_Unload event, make it normal again (not sure if it's necessary).

Also note that if your form's name is not Form1, you'll have to change all the "Form1"s in the above code to your form's name.

Good luck with your program ;)

itay222
Dec 21st, 2000, 10:08 AM
firstly, excuse me for being so lazy and looking
for complete answers without research from myself...
now,
the (very nice) samples there (http://www.ur.co.nz)
demonstarte memory access to picture_box array.

using this, i can indeed make changes to the picture.
however, the colors i can use are the colors of the
picture inside the pictureBox.

the only way i can "compose" my own RGB color
is using picturebox1.pset x,y,&Hrrggbb. and this is
not good (slow), plus i don't know what will happen when
i combine this two approaches.

so, still, can any1 help?

again, the task:
1. pset(x,y,color), and also
2. setpal (color,r,g,b)
3. fast.


10x, itay.

Jotaf98
Dec 21st, 2000, 03:53 PM
I haven't tested that demo much, but my guess is that you can load a blank image, then modify all the pixels in it.

If the picture is a GIF with a custom palette, you'll use a custom palette; if it's a 24-bits BMP, you'll be able to use the RGB mode.

Try it, it might work.