Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Drawing Freeimage.dll DIB To PictureBox *RESOLVED*


The topic pretty well says it all. I've got Freeimage loading and saving image files fine in vb6 with the latest wrapper - but I'd like to be able to display it to a picturebox - and it's not obvious from the documentation how to do it.

Any help would be greatly appreciated.

Thanks



Edited by - BMan2 on 10/10/2005 3:23:26 AM




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
PictureBox And Drawing
Hello.
I have some questions about picture boxex...
Can they stretch a picture to their size like the ImageBox can?
(You cannot draw with the ImageBox can you?)

When I draw a some lines in a PictureBox using the "line" command and after that load a picture or move thing inside the PictureBox all my drawing disappears. That is bad since I would like to have tiles there constantly, tiles I can change. therefore the drawing.

Well, if anybody could tell me about that I would appreciate it.
Thank you in advance.

Drawing Graphics On A Picturebox
I want to begin by saying I am a student, and am looking for some guidance. I have made a program in which the user selects a line color, line width, and drawing tool from comboboxes. When they press draw, and press the mouse down on the picturebox they draw their selected graphic. I have lines and rectangles working, and am working on the freehand drawing. I also have a button that they can press to clear the drawing area so they can re-draw without running the program again. The question I have relates to the visibility of the line/rectangle on the picturebox. The draw item is now displayed after the user releases the mouse button but I want the drawing to be displayed from mousedown to mouseup. I have done many internet searches and cannot come up with a solution. Your able assistance would be appreciated.

Drawing Text On A Picturebox
Hey,

I'm looking for some advice on drawing text on a picturebox. I want to
be able to draw some text on a picturebox and then be able to select it (put a dashed box around it) and also able to move that text around. It
would also need to be able to print the text at any angle. Can anyone give me some guidance on the best way to do this....please.

Thanks

Drawing Lines In Picturebox
I have a picture box that is 500 pixels wide. I need to have a white line drawn every 25 pixels across the top ttat would extend down 2 pixels in length. I have never worked with the drawing commands so could someone point me in the right direction to get this done????

Thanks Rick

Questions About Drawing On A Picturebox?
Using: Visual Basic 2005 Express Edition Beta 2

Ok i'm making a program like a text editor, and a little drawing thing:

1] Is there anyway to clear the picturebox? Say I drew something on it with a brush onto the picturebox, how do I clear it?

2] The user can choose the Width & Length of the brushable picturebox - I made it so when the user puts in any Width size of more than 340 in the textbox a msgbox will pop up saying it has to be lower. But I need to know how keep the
size of the picturebox at its default when they put a number larger than 340 in the Width textbox. Here's some code -

I don't know why I made it Horizontal instead of Width, and Vertical instead of Length, It was pretty late and I was sleepy


Code:
Dim vert As String
Dim horz As String
Dim verti As Integer
Dim horiz As Integer
verti = txtVERT.Text
horiz = txtHOR.Text
vert = Val(txtVERT.Text)
horz = Val(txtHOR.Text)

If vert > 250 Then MsgBox("Vertical Size can only be 1-250 px!")

If horz > 340 Then MsgBox("Horizontal Size can only be 1-200 px!")

PictureBox1.Height = vert
PictureBox1.Width = horz
End Sub
Any help would be appreciated so please help =]

Drawing To PictureBox Using Pure API (GDI)
I am trying to learn to draw graphics using GDI.

The code I have come up with messes up the screen something terrible, but after a few repaints everything corrects itself.

My Ellipse call does not work properly either, but I am not worried about that at this point.

If anyone can help it would be appreciated.

Here is my code:

Code:
Option Explicit


Private Declare Function GetDC Lib "user32" _
(ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" _
(ByVal hwnd As Long, _
ByVal hdc As Long) As Long


Private Declare Function CreatePen Lib "gdi32" _
(ByVal nPenStyle As Long, _
ByVal nWidth As Long, _
ByVal crColor As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" _
(ByVal crColor As Long) As Long
Private Declare Function SelectObject Lib "gdi32" _
(ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
(ByVal hObject As Long) As Long
Private Declare Function Ellipse Lib "gdi32" _
(ByVal hdc As Long, _
ByVal X1 As Long, _
ByVal Y1 As Long, _
ByVal X2 As Long, _
ByVal Y2 As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" _
(ByVal hdc As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" _
(ByVal hdc As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" _
(ByVal hdc As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long) As Long
Private Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Long, _
ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, ByVal xSrc As Long, _
ByVal ySrc As Long, ByVal dwRop As Long) As Long

Private Const PS_SOLID = 0
Private Const SRCCOPY = &HCC0020

Dim DisplayMethod As Integer
Dim bQuit As Boolean


Private Sub Form_Load()
Command1.Caption = "Run"
Command2.Caption = "Stop"
Command3.Caption = "Switch"
Randomize Timer
End Sub

Private Sub Command1_Click()
Do
DoEvents
bQuit = False
Call UpdateFrame
Loop Until bQuit
End Sub

Private Sub Command2_Click()
bQuit = True
End Sub

Private Sub Command3_Click()
If DisplayMethod = 0 Then
DisplayMethod = 1
Else
DisplayMethod = 0
End If
MsgBox DisplayMethod
End Sub

Private Sub UpdateFrame()

Dim i As Long

Dim hChild As Long
Dim hdc As Long
Dim myPen As Long
Dim myBrush As Long

Dim hdcChild As Long
Dim hdcBuff As Long
Dim bmpBuff As Long

Select Case DisplayMethod

Case 0 'draw direct to PictureBox

hChild = Picture1.hwnd
hdc = GetDC(hChild)

For i = 0 To 19

DoEvents

myPen = CreatePen(PS_SOLID, 1, RGB(Rnd * 255, Rnd * 255, Rnd * 255))
myBrush = CreateSolidBrush(RGB(Rnd * 255, Rnd * 255, Rnd * 255))

Ellipse hdc, _
Int(Picture1.ScaleWidth) * Rnd, _
Int(Picture1.ScaleHeight) * Rnd(0), _
Int(Picture1.ScaleHeight) * Rnd(0) + Abs(Rnd * 50 - 50), _
Int(Picture1.ScaleHeight) * Rnd(0) + Abs(Rnd * 50 - 50)

Next i

DeleteObject (myBrush)
DeleteObject (myPen)
ReleaseDC hChild, hdc

Case 1 'draw to buffer then BitBlt

hdcChild = Picture1.hdc
hdcBuff = CreateCompatibleDC(hdcChild)
bmpBuff = CreateCompatibleBitmap(hdcChild, Picture1.Width, Picture1.Height)
SelectObject hdcBuff, bmpBuff

hdc = hdcBuff

For i = 0 To 19

DoEvents

myPen = CreatePen(PS_SOLID, 1, RGB(Rnd * 255, Rnd * 255, Rnd * 255))
myBrush = CreateSolidBrush(RGB(Rnd * 255, Rnd * 255, Rnd * 255))

Ellipse hdc, _
Int(Picture1.ScaleWidth) * Rnd, _
Int(Picture1.ScaleHeight) * Rnd(0), _
Int(Picture1.ScaleHeight) * Rnd(0) + Abs(Rnd * 50 - 50), _
Int(Picture1.ScaleHeight) * Rnd(0) + Abs(Rnd * 50 - 50)

Next i

DeleteObject (myBrush)
DeleteObject (myPen)

Dim ret As Long
ret = BitBlt(hdcChild, _
0, _
0, _
Picture1.Width, _
Picture1.Height, _
hdcBuff, _
0, _
0, _
SRCCOPY)

DeleteObject bmpBuff
DeleteDC hdcBuff

End Select

End Sub

Drawing, Transparent, Picturebox, Help!
Ok Here is my setup:

I have 2 imagelist(s) - With 10 images (all have transparency)

and one picturebox

How can I use the imagelists "Draw" sub to draw onto a HDC but ignore the background color... Basicly keep the pictureboxes background color...

Is this possible or do I need to use bitblt? and if so... how can I use bitblt and an imagelist...



Post Resolved:

I just used my API viewer 2004, and looked up some constants and found ILD_TRANSPARENT!
works great!

Best Method For Drawing To Picturebox
I use VB6.

I am drawing to a 1000x1000 picturebox with different colours based on areas of a map. I am trying to work out the fastest way to draw this pixel by pixel.

At the moment I am using setpixel, which is okay if I am not zoomed in but when I zoom in it not only takes serious amounts of time, but also memory and it crashes with the "can't create AutoRedraw image" error (meaning the buffer's too large)..BTW zooming in multiplies the picturebox size because of what I am doing, so 3x zoom is a 3000x3000 picturebox.

I have tried using BitBlt but I can't seem to work out how to draw specific colours to each pixel with it if at all possible. I've realised I *could* have a legend and have BitBlt grab the image from there to paste onto my map, and I might have to do that if I can't find a better solution.

I have uploaded a sample of a zoomed in (4x zoom so each box is 3x3 with a black border) at http://i10.photobucket.com/albums/a117/SmUX/sample.gif

Has anyone got any thoughts or suggestions for the best way to achieve this? Hopefully with some code or link to where to learn about it :-)

Is there any way to draw squares of a specific colour to a specific point of a picturebox, perhaps?

Question Regarding Picturebox / Drawing In One
in the project i am working on, i have a picturebox the user can load a bitmap into and draw on. for right now, i only have two types of lines available to use: freehand and straight line. I have both types working, but have a small problem with the straight line code. When the user goes to draw a straight line and moves the mouse, it draws the line fine, but in order to erase the last line drawn, i used some other code to draw over the last line with Picture1.backcolor. What i want to know is, how can i make my straight line tool work like the one in MS Paint, where it draws the lines and preserves the picture and other drawn lines underneath it?

Drawing In PictureBox Permanently?
How can I use Line or PSet methods on PictureBox and leave the results on it? Normally, when the form is redrawed, this content is cleared.

I would also like to move this drawing in PictureBox. I don't want to redraw the picture manualy with same methods...

Save Picturebox Drawing
I have drawn rectangles at run time in a picture box using .LINE method. Is is possible to save such a drawing as a JPEG or Bitmap file?? I want to be able to load the picture onto a picture box and change some of its propetied using picture1.picture ....

Drawing To Picturebox's Picture Property
hi everyone.

i am currently working on an on-going project for a home made remote desktop application for use at home. however i have run into a little snag.....

the way in which my program works is as follows:
-the desktop is captured and transfered to the forms image using bitblt
-the form image is then transfered to a picture box
-a makeshift(deliberately) mouse cursor is printed to the picture box at the current location of the users mouse(currently using picture1.Pset)
-picture is saved using savepicture (picture1.picture)
***below steps are not relevent****
-picture is encoded and compressed and sent off to remote user.
------

okay, the problem i am having is drawing my (makeshift)mouse cursor to the picturebox's picture property. it is drawn on fine and can be seen visually but when it comes to saving the picture (using the savepicture command) my drawn cursor does not appear.

Now, i HAVE worked out that the drawn on mouse cursor is only in the picturebox's image property and not in the picture property.

does anyone have any ideas on how i might (without setting the image property of the picturebox to picture property[causes inconveniences]) draw the makeshift cursor direct to picturebox's picture property itself without overwriting the existing picture and prefferabley without too much mucking around in the process??

thanks guys.

Mattsa.

Clear All The Drawing In A PictureBox Control
I know the PictureBox control come with the Cls method. But how am i can implement this in API function call? Can I use SendMessage API?

Drawing A .jpg In Fixed Hight PictureBox...
Hi there, I am triing to put a lot of differant pictures in a picturebox, one at the time, from a list but...
Every Picture has different heights and widths.
The picture box should have a fixed height and the width should adjust to the picture.
I can't just put the stretch proprety to true because the picture will be distorted.
Here is how the picture loads in the Picturebox:

Code:If GetFirstPic(GetPicID(Me.AdoPro.Recordset.Fields("fldRefNumber"))) <> "-" Then
    picPreview.Picture = LoadPicture(GetFirstPic(GetPicID(Me.AdoPro.Recordset.Fields("fldRefNumber"))))
end if

I can't figure out how it is done.

thankz in advance

Howto Erase PictureBox Drawing?
HI all
I have drawn a circle inside a picturebox using DrawCircle method.
and a few other lines and rectangles are also been drawn.
How can I erase the Circle alone without changing lines and rectangles?
In VB6 it was possible to erase using redraw the circle in PicNotMaskPen(7)
DrawMode.
But, it is not working with eVB.
and 'cls' method erases the whole drawing from the picture, But I just want
to erase only the circle.
Any other alternative?

Free Hand Drawing In Picturebox
Can someone help me? Gotta developed a program that allows the user to write or draw in a picture box and save it. Desperately in need of help.

How-to: Drawing With Picturebox (simple && Sample Code ;) )
edited

mistake in this file. get the next one, please

--------
www.tac822.net - tablatures i acords per guitarra en català
www.tac822.net - tabs and guitar chords in Catalan.

- Catalonia IS a nation -

Edited by - johnminkjan on 11/23/2005 10:57:11 AM

Drawing A Line In A Picturebox - From Within A User Control
I've been trying to build an ActiveX control, comprised of a Picture Box. When I goto UserControl_Initilization, and include a line like: “Picture1.Line (10,10)-(100,100),vbRed” nothing appears. If I move the line down to the Picture1.Paint method, then it works. Why won’t this work in a UserControl method?


Thank,

- Don


dschin@vnet.ibm.com

Drawing Lines In PictureBox And UserControls ( Not Working For Me )
Hello all,

I am trying to create a UserControl (UC) and within the UC I wanted to draw my own border around it. The problem is trying to create the lines. If you use

UserControl.Line (X1, Y1)-(X2,Y2), Color, BF




or


' This is contain within the UserControl
PictureBox.Line (X1, Y1)-(X2,Y2), Color, BF




Both raise a compile error of ( Expect: = ). So I change the syntax around to the following


' This is contain within the UserControl
PictureBox.Line X1,Y1, X2, Y2, Color, BF




Ok, this doesn't give me a compile error, but it sure doesn't work correctly. So out of desperation I put a PictureBox and two Lables ( Text1 and Text2 ) within a form an added the following code to see if I can figure it out what in the world is going on.


private m_X as Single
private m_Y as Single

private Sub Picture1_Click()
With Picture1
.DrawWidth = 1
.DrawStyle = vbSolid
.FillColor = vbRed
.ForeColor = vbRed
.CurrentX = 10
.CurrentY = 10
.Line 1, 1, m_X, m_Y, vbRed, 0
End With

End Sub

private Sub Picture1_MouseMove(Button as Integer, Shift as Integer, X as Single, Y as Single)
Text1.Text = X
m_X = X
Text2.Text = Y
m_Y = Y
End Sub




But this doesn't work. It seems that when I move the mouse vertically then click within the Picture box the ending x coordinate of the line moves, but no matter where I move the mouse on the horizontal plane does it affect the ending x coordinate. Please, what am I missing????? I am so confused. In addition, I don't want to fill create any boxes or fill anything, but if I leave off the BF it tells me the arugment is not optional. What is the deal here? This is also try for the Color aspect of the parameters being passed into the Line method. If you search the on-line by pressing F1 it list the standard


object.Line [step] (x1, y1) [step] - (x2, y2), [color], [b][F]




Which doesn't seem to apply for the the Line method for either the PictureBox or a UserControl.

Mark

Underlying Graphics Erased In PictureBox When Drawing Rectangles
The following code works if I have an empty white PictureBox.

If I load a bitmap image into the PictureBox, the underlying graphics are erased wherever the outline rectangle was
(the focus rectangle doesn't erase the graphics).

Any thoughts as to how I might correct this?


Code:
Option Explicit

Dim X2 As Single
Dim Y2 As Single
Dim X1 As Single
Dim Y1 As Single


Private Sub Form_Load()

Form1.ScaleMode = vbPixels

Picture1.ScaleMode = vbPixels
Picture1.BackColor = vbWhite
Picture1.DrawStyle = vbDot
Picture1.Width = 246
Picture1.Height = 140
'Picture1.Picture = LoadPicture(App.Path & "MyBitmap.bmp")

End Sub


Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

'erase old focus rect
Picture1.DrawStyle = vbDot
Picture1.DrawMode = vbInvert
Picture1.Line (X1, Y1)-(X2, Y2), vbBlack, B

'redraw old outline black so it can be erased
Picture1.DrawStyle = vbSolid
Picture1.DrawMode = vbCopyPen
Picture1.Line (X1 - 2, Y1 - 2)-(X2 + 2, Y2 + 2), vbBlack, B

'erase old outline
Picture1.DrawStyle = vbSolid
Picture1.DrawMode = vbNotXorPen 'vbInvert
Picture1.Line (X1 - 2, Y1 - 2)-(X2 + 2, Y2 + 2), vbBlack, B

'record start coordinates
X1 = X
Y1 = Y

'record end coordinates
X2 = X1
Y2 = Y1

End Sub


Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = vbLeftButton Then

'erase old focus rect
Picture1.DrawStyle = vbDot
Picture1.DrawMode = vbInvert
Picture1.Line (X1, Y1)-(X2, Y2), vbBlack, B

'draw new focus rect
Picture1.DrawStyle = vbDot
Picture1.DrawMode = vbInvert
Picture1.Line (X1, Y1)-(X, Y), vbBlack, B

'update end coordinates
X2 = X
Y2 = Y

End If

End Sub


Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

'draw new outline
Picture1.DrawStyle = vbSolid
Picture1.DrawMode = vbCopyPen
Picture1.Line (X1 - 2, Y1 - 2)-(X2 + 2, Y2 + 2), vbRed, B

End Sub

Drawing A Border Around My Text - Picturebox - Line Method
Hi there everyone,

What I'm trying to do is the following:
I have a method called "PrintLine", that print a line on my picturebox, all no trouble.
Everything is figured out correctly, I think.
Now, in my PrintLine method, I've got a boolean, if you want a borders around it, how many, and what is the borderspace, with that information, I call my border routine. And that is where the problem lies ... and I can't understand it.
Code:Private Sub PrintLine(ctl As PictureBox, str As String, LineNum As Integer, Optional Border As Boolean = False, Optional Borderspace As Integer = 0, Optional NumberOfBorders As Integer = 1)
mCurrentX = MarginLeft
mCurrentY = MarginTop + (LineNum - 1) * LineSpace
ctl.CurrentX = mCurrentX
ctl.CurrentY = mCurrentY
ctl.Print LineNum & Space(4) & str
If Border = True Then
Call CreateBorder(ctl, mCurrentX, mCurrentY, ctl.TextWidth(LineNum & Space(4) & str), ctl.TextHeight(LineNum & Space(4) & str), NumberOfBorders, Borderspace)
End If
End Sub
This sub is ONE HUNDRED PERCENT working, but I'm just giving it to you to see how I call my Createborder.
Here it is:
Code:Private Sub PrintLine(ctl As PictureBox, str As String, LineNum As Integer, Optional Border As Boolean = False, Optional Borderspace As Integer = 0, Optional NumberOfBorders As Integer = 1)
mCurrentX = MarginLeft
mCurrentY = MarginTop + (LineNum - 1) * LineSpace
ctl.CurrentX = mCurrentX
ctl.CurrentY = mCurrentY
ctl.Print LineNum & Space(4) & str
If Border = True Then
Call CreateBorder(ctl, mCurrentX, mCurrentY, ctl.TextWidth(LineNum & Space(4) & str), ctl.TextHeight(LineNum & Space(4) & str), NumberOfBorders, Borderspace)
End If
End Sub
Private Sub CreateBorder(ctl As PictureBox, strTop As Integer, strBottom As Integer, strWidth As Integer, strHeight As Integer, Borders As Integer, Borderspace As Integer)
    Dim LT(2) As Integer
    Dim LB(2) As Integer
    Dim RT(2) As Integer
    Dim RB(2) As Integer
    Dim i As Integer
    Dim brdrspace As Integer
    brdrspace = 0
    For i = 1 To Borders
        brdrspace = Borderspace * (i)
        LT(0) = strTop - brdrspace - ScaleX(ctl.DrawWidth * (i - 1), vbPoints, vbTwips)
        LT(1) = strBottom - brdrspace - ScaleY(ctl.DrawWidth * (i - 1), vbPoints, vbTwips)
        LB(0) = strTop - brdrspace - ScaleX(ctl.DrawWidth * (i - 1), vbPoints, vbTwips)
        LB(1) = strBottom + brdrspace + strHeight + ScaleY(ctl.DrawWidth * (i - 1), vbPoints, vbTwips)
        RT(0) = strTop + brdrspace + strWidth + ScaleX(ctl.DrawWidth * (i - 1), vbPoints, vbTwips)
        RT(1) = strBottom - brdrspace - ScaleY(ctl.DrawWidth * (i - 1), vbPoints, vbTwips)
        RB(0) = strTop + brdrspace + strWidth + ScaleX(ctl.DrawWidth * (i - 1), vbPoints, vbTwips)
        RB(1) = strBottom + brdrspace + strHeight + ScaleY(ctl.DrawWidth * (i - 1), vbPoints, vbTwips)
        ctl.Line (LT(0), LT(1))-(LB(0), LB(1)) 'linkse lijn
                Debug.Print "Linkse lijn: (" & LT(0) & ", " & LT(1) & ")-(" & LB(0) & "," & LB(1) & ")"
        ctl.Line (LT(0), LT(1))-(RT(0), RT(1)) 'bovenste lijn
                Debug.Print "Bovenste lijn: (" & LT(0) & ", " & LT(1) & ")-(" & RT(0) & "," & RT(1) & ")"
        ctl.Line (RT(0), RT(1))-(RB(0), RB(1)) 'rechtse lijn
                Debug.Print "Rechtse lijn: (" & RT(0) & ", " & RT(1) & ")-(" & RB(0) & "," & RB(1) & ")"
        ctl.Line (RB(0), RB(1))-(LB(0), LB(1)) 'onderste lijn
                Debug.Print "Onderste lijn: (" & LB(0) & ", " & LB(1) & ")-(" & RB(0) & "," & RB(1) & ")"
    Next i
End Sub
Don't look for the Debug things... it's in Dutch, but that's just printing the coördinates used.
Everything SEEMS all right, but it isn't.
The LAST line drawn, doesn't get drawn completely or something...
I'll attach the project and you can have a run on it yourself.
Just run it and click the commandbutton.
A third line WITH border will appear, but the border has one corner not complete... the bottom left one.

If anyone can help me sorting this out... I'd be very grateful
Thanks

Search before you ask - if you don't know where to search, ask before you search

Edited by - breakfast3001 on 7/10/2004 4:16:15 AM

Drawing A Triangle **Resolved**
I have a program where the user enters lengths of a triangle into textboxes. Then it tells what type of triangle it is. But now i want to add a function that will draw the triangle for the user to see as well. This is my code i ahve so far. Im clueless on what to do next to draw it.


VB Code:
'side aDim a As Single'side bDim b As Single'side cDim c As Single   Private Sub cmdexit_Click()'CLOSES THE PROGRAM!!!!!!!!Set frmtri = NothingUnload MeEndEnd Sub   Private Sub cmdTri_Click()'if an error occursOn Error GoTo errorhandler'assigning values to varsa = Val(txta.Text)b = Val(txtb.Text)c = Val(txtc.Text)'no triangleIf a + b < c Or b + c < a Or a + c < b ThenMsgBox "This isn't a triangle."GoTo doneEnd If'scalene triangleIf a <> b And b <> c And a + a <> c ThenMsgBox "This is a scalene triangle."GoTo doneEnd If'equilateral triangleIf a = b And b = c And a = c ThenMsgBox "This is an equilateral triangle."GoTo doneEnd If'isosceles triangleIf a = b Xor b = c Xor a = c ThenMsgBox "This is an isosceles triangle."GoTo doneEnd If'label that it goes to when it is done'identifying the triangledone:'checks to see if they want the triangle drawnIf chkDraw.Value = 1 Then'goes tot draw functionCall drawEnd IfExit Sub'code label for errorserrorhandler:'tells user there was an errorMsgBox "An error has occurred.  Most likely the numbers were too big!", vbCriticalEnd Sub   Public Function draw()'resizes the lengths of the triangleDim a2 As SingleDim b2 As SingleDim c2 As Single'resizes the lengths of the trianglea2 = a * 160b2 = b * 160c2 = c * 160'draws the first line which always starts at'480,1680.  And then it draws it downwardlnea.X1 = 480lnea.Y1 = 1680lnea.X2 = 480lnea.Y2 = 1680 + a2'then i have no clue where to go from hereEnd Function

Difficult Drawing {Not Resolved}
Hello All memebers
I Have make a code that take the data from 2 msflexgrid to draw (Inner and outer holes) with depths but relley i failed to complete it
please check my code and i hope you are able to help me
Thanks alot for advice


Edit:
I think that may problem may be related to API drawing !!!!


Egyptian Man

Edited by - khaledagwa on 8/17/2004 10:04:31 AM

Flickering When Drawing Shape *** RESOLVED ***
Hi,

In my program I have a large picture box which is displaying the contents of a map. On top of this picture box I have a number of small images which represent the locations where 'work' was done. I also allow the user to zoom a region (similar to most graphics programs), by clicking and dragging the mouse to select the desired region.

When the user is doing this, I draw a shape which shows the user the currently selected region. The problem is that the images I have on the picture box flicker way too much as this is happening and looks very unprofessional.

It's probably better if you see this effect for yourself, so I have included a simplified example of what is happening. To see the problem, zoom a large region surrounding all of the images on the form by clicking and dragging the mouse.

Does anyone know a way of preventing this?

Anyone Use Freeimage?
I just downloaded free image so i could use my .PNG pictures in visual basic, but i dont even know how to get it on vb, can someone help?

Freeimage And PNG
Right, I am using Freeimage for it's ability to load and save PNGs. Fair enough, and it seems to work fine. If I want to save to 8 or 24 bit that is.

What I want to do is to save a PNG as 4bit (16 colours). Note that the original PNG is 4bit, but the BPP fuction from Freeimage reckons it is 8 (FreeImage_GetBPP). There also doesn't seem to be a convert to 4bit function listed (does have 8 and 24).

Can't find anything on many searches, and all VB solutions (not just Freeimage) seem to go the same way (all based on libpng with zlib maybe?). Infact all the freeware graphic editors that handle PNG did the exact same thing. Some even detected the image was 4 bit, but none actually saved as 4 bit. Either 8 or 24 bit (think some had 16 bit too). After a lot of searching the only thing I found worked was PSP shareware (don't know about photoshop). But I don't want to use an external app.

Overall though all I really just want to be able to do is to modify a PNG file from within VB. And it's got to keep it's original colour depth. And that includes 4bit (v.important to what I want to do annoyingly). That's about it really.

Anyone got any ideas before I just make it link to PSP (which will really really annoy me)? Heh, if not then if you can tell me how to make PSP appear in a form I would settle for that.

Cheers

I Need Some Help With Freeimage!
Hi everybody,
How do I copy one freeimage DIB onto another? I've tried FreeImage_Paste but that seems to negate the image's color. Here is my code:

FreeImage_Initialise
Dim gheight, gwidth, gsize As Long
gheight = 2000
gwidth = 2000
gsize = gheight * gwidth * 3
fiGraphics = FreeImage_Allocate(gheight, gwidth, 8)
ptPalette = FreeImage_GetPalette(fiGraphics)
'Set palette to greyscale
Dim a, b As Integer
'palettes(0).rgbBlue = 255
'palettes(0).rgbGreen = 255
'palettes(0).rgbRed = 255
For a = 0 To 255
palettes(255 - a).rgbBlue = a
palettes(255 - a).rgbGreen = a
palettes(255 - a).rgbRed = a
Next a

'Copy our palette to freeimage palette
CopyMemory ByVal ptPalette, palettes(0), 256 * 3

fiImage1 = FreeImage_Load(FIF_BMP, "c:" + declares(1).FileName, 0)

FreeImage_Paste fiGraphics, fiImage1, 0, 0, 428
FreeImage_Save FIF_PNG, fiGraphics, "c: est.png"

FreeImage_Unload fiImage1
FreeImage_Unload fiGraphics
FreeImage_DeInitialise


Also, I've tried to set all of the DIB's bits to a certain colour using the following code:

Dim ptBits As Long
ptBits = FreeImage_GetBits(fiGraphics)
FillMemory ByVal ptBits, gsize, 255

But it just crashes the program... Whats wrong with my code??

PNG Freeimage
Hi, I want to use png's in my program, but i've been searching this whole forum and i did found some useful information, but i don't know how to use those information. for example like how do i even use the freeimage.dll? how would i call it in my program to display png's? please, i need steps by steps from top to bottom. if you include source code in ur posts, please include the whole code. thanks in advance.

FreeImage.DLL Help
Hi,
I'm using freeimage.dll (VB) and I want to convert 24bit jpg image to a 8 bit 4/16 colors and only get greysacale images. Does anyone can give me a help?
Thank you

Marino Freitas
amarinofreitas@hotmail.com

FreeImage.dll
Hello, does anyone can help me to solve the following problem by freeImage.dll

i need to capture the whole desktop screen (bmp) and convert it to jpeg format, then resize the picture (jpg) finally save it into byte[] for send to another computer by winsock.

    Dim a As Long
    Dim b As Long
    a = MFreeImage.FreeImage_OpenMemory
    b = MFreeImage.FreeImage_SaveToMemory(FIF_JPEG, MFreeImage.FreeImage_CreateFromScreen, a)

the above it my first try coding, however it seem not work for archieve my requirement, hope have someone can help me! thx a lot

FreeImage

Freeimage Rotate
I am having trouble rotating an image using freeimage rotate functions. The functions appear to work, but the image does not get rotated. Here is the code I am using, perhaps someone more enlightened can see what I am doing wrong?

Dim bOK As Long
Dim DIB As Long
Dim Angle as Double

Angle=90

' load the file into the DIB
DIB= FreeImage_Load(FIF_JPEG, "Image.jpg", JPEG_DEFAULT)

If DIB <> 0 Then
' do the rotate
bOK = FreeImage_RotateClassic(DIB, Angle)
If bOK <> 0 Then
' save the rotated file
bOK = FreeImage_Save(FIF_JPEG, DIB, "Image.jpg",JPEG_DEFAULT)
End if
End if

Image.jpg should now be rotated, but it isn't!

I have also tried using 'FreeImage_RotateEx' , but with the same result.

Freeimage, Is It My Only Hope?
Anyone know where I could get a "How to do" on freeimage. Trying to get the tiff format to display in VB6.

Freeimage.dll (Abby?)
Freeimage.dll is used heavily in my application that faxes/emails clients.

While in heavy development, I run it uncompiled on the fax server.

Every so often, (usually after an error?) I get a "cannot find freeimage.dll". Stopping and rerunning the application doesn't help, I have to exit VB completed and restart my project.

Is there anyway around this? I can't register the dll, and can't include a reference in my project (because it's a c dll, right?).

I'm setting up an upgrading launcher and trying to get it to compile now. Hopefully this will solve the problem. Otherwise, what can I do to stop this?

How Do I Save An Image Using Freeimage?
Hi everybody,
For my program I need to save the contents of a directdraw surface to a picture file. I have tried savepicture but it only saves as bmp in 24-bit resolution. I want to save in 8-bit resolution and in png or jpg to save size. Here is my old code:


Private Sub Form_DblClick()
Dim r3 As RECT
DirectX.GetWindowRect frmMain.hWnd, r3
r3.top = r3.top + transfrm.Y
r3.left = r3.left + transfrm.X
r3.Right = r3.Right - transfrm.X
r3.Bottom = r3.Bottom ' - transfrm.Y

Picture1.Width = r3.Right - r3.left
Picture1.Height = r3.Bottom - r3.top

Primary.BltToDC Picture1.hDC, r3, DDRect(0, 0, Picture1.Width, Picture1.Height)
SavePicture Picture1.Image, "c:primary buffer.bmp"
End Sub


I want to use freeimage somehow to save Primary's surface as a 8-bit png. How do I do this?
Thanks,
Stefan.

Freeimage.dll And The Freeimage_ConvertFromRawBits Function
I am stuck with something and was wondering if any of you have had any experience with it. I am using the Freeimage_ConvertFromRawBits function which sounds promising, but am struggeling to get it to work. The image will make it to the destination picturebox, but its just a black image, the size is right but no pixels. I am using the below code which BMPDATA is being populated from a bitmap that is being unzipped into memory, from a file is not an option for this project, I have confirmed that the array is being populated, and has lots of data to pass by the time this function is called. I am able to use the BMPDATA array with setpixel to display the bitmap (just to prove the data is worthy). I have searched google as well as read over the freeimage manual for countless (im up to about 20 so far) hours with out success. The image in this case is a 24bit BMP. Any suggestions?



Code:
Dim BMPDATA() as byte

Sub Unzip()
' All the unzipping code is here
End Sub

Sub Imagefrombits(dest as picturebox)
dim DIB as long

FreeImage_Initialise
DIB = FreeImage_ConvertFromRawBits(BMPData(), BMPInfoHeader.biWidth, BMPInfoHeader.biHeight, BMPInfoHeader.biWidth, 4, 0, 0, 0)
dest.AutoRedraw = True
If DIB <> 0 Then
If FreeImage_BMP_From_DIB(DIB, hBitmap) = True Then
FreeImage_RenderBitmap hBitmap, dest.hDC
If FreeImage_DIB_From_BMP(hBitmap, DIB_New) = True Then
FreeImage_RenderDIB DIB_New, dest.hDC
FreeImage_Free DIB_New
End If
DeleteObject hBitmap
End If
FreeImage_Unload DIB
End If
FreeImage_DeInitialise
End Sub

Thanks
C

Edit: added vb tags

I Need Some Help With This Little PictureBox Program (RESOLVED)
I have a little project here that I wrote to be used in a bigger application but I cant get it to work properly.

It is a 2 form application. One form you use to search for a picture. The second form you use to select a certain area within the picture. Then the first form displays that area in a picturebox.

I would really appreciate anybodies help with getting this to work.


Thanks in advance.

Picturebox And Circles (Resolved)
Hrmm, so here in the last day or two I'm been working on a personal print dll with print previewing and all built in and I've gotten to something that I just can't figure out.

Everything is going together and working great, and I decided to add the ability to print a circle. Well printers and pictureboxes have a function for that as you probably know


VB Code:
object.Circle (x,y),radius, [color, start,end,aspect]


So I put it in thinking there would be no problems and low and behold the picture box preview dosn't show it. Yet when I print it it prints out just fine.

And I'm using the same exact code for both (and I mean same exact hehe I just have a variant that I set to a printer or to a picturebox for outputting).. so it dosn't make sense as to why it dosn't show in the picturebox.

Is there something I'm missing here? Everything else works fine, text, lines, graphics.... just that dern circle deciding to rack my brain.

Steven

PictureBox Challenge! *RESOLVED*
Hi!
I'm trying to make something like a "skin"(like the one for WinAmp) system for my application. So i wanna do it like this: Make the form borderless, and set picturesboxes instead of borders. But! I have a problem, when i wan't to resize my form, i have to stretch the images in the pictures box, or copy them... maybe make an array that'll make a lot of picture boxes... How would you apporach this problem !? I'm not quite sure what would be best... If you would stretch it, could you give me basic code on how to ?? Thanks in advance!!

Cheers !

PictureBox Thumbnail - RESOLVED
Hi,
How can I load a picture into a picture box and show it as a thumbnail (similar to using image stretch).
I CANT use the image control as I am creating a print preview of the picturebox.

I'm using the following code but its not working correctly

Code:
Picture1.Picture = LoadPicture(cmd1.FileName)
Picture1.Cls
Picture1.PaintPicture Picture1.Picture, Picture1.Left, Picture1.Top, Picture1.ScaleWidth, Picture1.ScaleHeight


Thanks

Selection In A PictureBox (Almost Resolved)
How can I draw a selection rectangle like the one in paint for letting my user choose a part of a picture for doing something to it?
I.E. A zoom...

I have partially solved this by using a shape inside the picturebox and resizing it in the picture Mouse_Move (After the event Mouse_Down happened) and stopping it when the event Mouse_Up occured.

The problem would be with the user selecting backwards. An error happens when this happens (I set an absolute value to solve this but still it was just for avoiding the error, not to solve the wrong thing)

How could I solve this? Please help me!

(Oops.. I forgot to tell you I add my project so you can see what I achieved and what I am trying to get... I will add it in my next post)

** Resolved ** Paintpicture In Picturebox
Hello,

In a Sub, I paintpicture, draw and write in a Picturebox :

Picture1.PaintPicture Image1(0).Picture, etc...
Picture1.Line etc..
Picture1.Print "writing in it"

In another Sub, I need to access the Picture1.Picture property to copy it in the clipoboard :

Clipboard.SetData Picture1.Picture, 2

Well... nothing happens, clipboard remains empty, and when watching the value of Picture1.Picture at this moment it is = 0 ! (but the graphics is still correctly drawn on the screen). Are the paintpicture, line etc.. operations "non permanent" ? How can I grab the content drawn on the picturebox to put it in th Clipboard.

Ideas ?

Thanks

*RESOLVED* Disappearing PictureBox?
Hey everyone-

 I have a picture box that's filled with the .PSet method- everything's fine there. But I found that when I move another window over this picuture box, I lose any parts of my picture that the other window covered. It also happens when I minimize and then maximize my window- the whole picture is gone!

I had an idea about using an array to store the data, and then re-drawing the picturebox on certain events, but I'm confused on exactly which events and how to use the array. Can anyone help?



Edited by - McDoofus on 10/6/2003 3:26:28 PM

Moving An Image In The PictureBox (RESOLVED)
Hi there,

I'm trying to make a button that enables to move an image in a picture box.
For example when I click and drag the mouse to left the program makes the picture in the picture box move "a bit" (to be defined) left...

Is it possible? Any input is apreciated!

Thanks in advance

What Do Fillstyle And FillColor Do In Picturebox?(*Resolved*)
I am trying to make a picturebox with crossing line with designed color. I tried codes like:


VB Code:
Private Sub Picture1_Paint()     Picture1.AutoRedraw = True        Picture1.FillColor = RGB(a, b, c)    Picture1.FillStyle = 5        Picture1.Refresh    End Sub


but it did nothing. I still has a empty picturebox on screen. Anyone has an idea how I would be able to do it?

I know a shape can do this easily but I would need to bitblt this picturebox later on and a shape does not meet my purpose.

Thank you in advance.

PictureBox Print Method - RESOLVED
When using the print method it appears once the text is printed it cannot be modified or cleared???

------------------------

I'm working on is printing a mixed label in a format of:

minutes mm/dd minutes

1020 1030 08/14 0730 0740

This has created some problems as the ending time (1030 in example -- ending time may vary depending on dataset) will sometime collide with the date. That is some of both the date and time will be printed at the same X location, making it appear as a double strike so it is illegible.

Using .CurrentX and .CurrentY to backup to clear the area by printing spaces does not seem to work.

object.Print Space(5)
object.Print Space$(5)

Any IDEAS??????

PictureBox On SSTab Issues [Resolved}
Using VB5, SP2.
Per Microsoft any SSTab issues corrected.


Tried the following code and can't get the string to print on the
picturebox.

Any suggestions appreciated.

Thanks
David



VB Code:
Private Sub SSTab1_Click(PreviousTab As Integer)    If SSTab1.Tab = 1 Then      With picTest         .ForeColor = vbBlack         .CurrentX = 10         .CurrentY = 10      End With      picTest.Print "AaBaCa"      picTest.Refresh                '<<added to see if needed a refresh   End If   End Sub

Clipboard Image To Fit Picturebox (RESOLVED)
i would like the image stored on my clipboard to fit in a picturebox which is much smaller than the origional shrink to fit sort of thing?

*Resolved* Maximum Picturebox Size Isn't Enough. How To Get More?
I have a picture box. It scrolls. I've run into a limitation. The biggest my picturebox can be is 16383. I need more space. Is it even possible to allow for a larger picture area?

Resolved How Can I Add New Controls To A Container Picturebox At Run Time?
I want to use a picturebox as a container for controls I add to my form on runtime using the Controls.Add method. The problem is that the controls are being created "behind" the picturebox (which is created on design time) instead of in it. How can I do do it so they are created inside the picturebox instead of being hidden behind it?

I've tried


Code:
Set MyNewControl.Container = MyPictureBox


but I get an "Object required" error message.
When I didn't use "Set" I got an "Object doesn't support this property or method" error message.
Any ideas?

Copyright © 2005-08 www.BigResource.com, All rights reserved