Hi!
Im using a pointer to plot pixels to a picturebox but i've got 2 problems with this...
1. ifi add + 1 to the colors, it adds more with pointers than with setpixel....(it gets brighter)
2. if i use setpixel, then i cant use the pointer anymore...
Printable View
Hi!
Im using a pointer to plot pixels to a picturebox but i've got 2 problems with this...
1. ifi add + 1 to the colors, it adds more with pointers than with setpixel....(it gets brighter)
2. if i use setpixel, then i cant use the pointer anymore...
hmm....wait.....
somethings wrong with this code but i cant figure out what!
VB Code:
For Angle = 0 To 180 TempY = Round(y + Cos(Angle * PiDiv180) * Height) HighX = Round(x + Sin(Angle * PiDiv180) * Width) LowX = x - (HighX - x) If TempY > 0 And TempY < UBound(pic, 2) Then For TempX = LowX To HighX Step 3 If TempX > 0 And TempX < UBound(pic, 1) - 3 Then r = pic(TempX + 2, TempY) + 1 g = pic(TempX + 1, TempY) + 1 b = pic(TempX, TempY) + 1 If r > 255 Then r = 255 If r < 0 Then r = 0 If g > 255 Then g = 255 If g < 0 Then g = 0 If b > 255 Then b = 255 If b < 0 Then b = 0 pic(TempX, TempY) = b pic(TempX + 1, TempY) = g pic(TempX + 2, TempY) = r End If Next End If Next
fixed the first error (+ some more i just discovered)
i still have the second problem!
heres the new code:
VB Code:
For Angle = 0 To 180 TempY = Round(y + Cos(Angle * PiDiv180) * Height) HighX = Round(x + Sin(Angle * PiDiv180) * Width) TempY = UBound(pic, 2) - TempY LowX = x - (HighX - x) HighX = HighX * 3 LowX = LowX * 3 If TempY > 0 And TempY < UBound(pic, 2) Then For TempX = LowX To HighX Step 3 If TempX > 0 And TempX < UBound(pic, 1) - 3 Then r = pic(TempX + 2, TempY) + 100 g = pic(TempX + 1, TempY) + 1 b = pic(TempX, TempY) + 1 If r > 255 Then r = 255 If r < 0 Then r = 0 If g > 255 Then g = 255 If g < 0 Then g = 0 If b > 255 Then b = 255 If b < 0 Then b = 0 pic(TempX, TempY) = b pic(TempX + 1, TempY) = g pic(TempX + 2, TempY) = r End If Next End If Next
i've experienced some crazy things here! i need alot of help i think...
I'll attach the whole code here!
One of the major problems is that i cant paint on any other picture than the one in my program...if i do, it paints wierd!
One other problem is that i cant paint outside the picture but still in the picturebox as i can with setpixel!
Please help me with this!
I see what you mean by anti-inter-operability between the two methods.
I got one thing working though
the problem you mentioned where it paints weird is due to this:
in order to update a window as quickly as it does, windows likes scanlines to have widthbytes fit 'neatly' with a multiple of 4.
since the picturebox you are working with is using 3 bytes per pixel, not all widths work properly if you're working with a 2d array.
a 1d array loop works like this
WBytes = bmp.bmwidthbytes
TopLeftByte = (bmp.bmheight - 1) * WBytes
BytesPixel = bmp.bmbitspixel / 8
AddWBytes = (bmp.bmwidth - 1) * BytesPixel
For Y = 0 to TopLeft step WBYtes
DrawRight = Y + AddWBytes
For X = Y to Drawright Step BytesPixel
XP2 = x+2
XP1 = x+1
r = buf(xp2)
g = buf(xp1)
b = buf(x)
thanks alot for the help!
was the code in the text file only for speeding up?
i dont really get the last code....
could you post what i should change in my code please!
thanks again! :D
that and more critical thinking
this will enhance speed further
dim XP1&
dim XP2&
..
For TempX = LowX To HighX Step 3 'do all x poses in circle (step 3=do one of the colors)
xp1 = tempx+1
xp2 = tempx+2
r = pic(xp2, TempY) ..
g = pic(xp1, TempY) ..
b = pic(TempX, TempY) ..
..
pic(TempX, TempY) = b
pic(Xp1, TempY) = g
pic(Xp2, TempY) = r
I converted what you have to 1d. 1d processing is slightly faster and will work properly with your other true-color bmps
it still doesnt work with other pictures!
thanks alot for the help!
"well that sucks." post one that is messed up if you have the time
try with this pic:
it works for me. i have a friend who was having image problems with a 'pointer' anim thing I sent. Different windows versions could be a factor. I did an experiment a while back. Thanks to a fine sub that a great man wrote, I am able to create a picturebox picture in 24 or 32-bit format. I have an older system with a 24 bit graphics card, and the 32 bit formatting works fine. Kudos to the windows team. You may find it worth researching: load a picture into and maintain 32-bit picturebox bit depth
ok...hmmmmm....
im pretty new to gfx so i dont know exactly how all there things work...all i wanted with the program that i've had some problems with was to learn how to use pointer....
if you're working with 24-bit array, widthbytes is the first thing to get a grip on.
if 32-bit, image handling is a snap, except for the fact that PSet and SetPixel, as well as mouse y say that y increases as you move down the form.
i know how to work with 32-bit pictures in vb using setpixel/getpixel or point/pset...