|
Hello!
I have been trying to resize an image (which is loaded to Picturebox1). The actual image size is greater than the size of Picturebox1. The picturebox1 uses strechimage attribute. My aim is to adjust the loaded image size and write it as a watermark on to another image. It writes but it doesn't resize the image according to size of the picturebox1 Width & Height. It is using the original size of the image when it writes.
If you have an idea why that happens, please let me know!
Thanks!
CODE::
Private Function DrawImageCallback(ByVal callBackData As IntPtr) As Boolean
'Test for call that passes callBackData parameter.
If callBackData.Equals(IntPtr.Zero) Then
' If no callBackData passed, abort DrawImage method.
Return True
Else
' If callBackData passed, continue DrawImage method.
Return False
End If
End Function
' Copy the watermark image over the result image.
Private Sub DrawWatermark(ByVal watermark_bm As Bitmap, _
ByVal result_bm As Bitmap, ByVal x As Integer, ByVal y As Integer)
Dim imageCallback As New Graphics.DrawImageAbort(AddressOf DrawImageCallback)
Dim imageCallbackData As New IntPtr(1)
' Create rectangle for adjusted image.
Dim destRect2 As New Rectangle(PictureBox1.Location.X, PictureBox1.Location.Y, PictureBox1.Width, PictureBox1.Height)
Dim es As Graphics = Graphics.FromImage(result_bm)
es.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
' Create image attributes and set large gamma.
Dim imageAttr As New ImageAttributes()
'imageAttr.SetGamma(4.0F)
' Draw adjusted image to screen.
es.DrawImage(watermark_bm, destRect2, x, y, PictureBox1.Width, PictureBox1.Height, GraphicsUnit.Pixel, imageAttr, imageCallback, imageCallbackData)
End Sub
|
|
|
|
|
Of course it doesn't resize the image. You are taking a portion of the watermark image the same size as the picturebox and draw that onto an area that is the same size as the picturebox.
---
b { font-weight: normal; }
|
|
|
|
|
Yes! you are right about it however I am dealing with a streched image. The actualy size of the image is greater than the Picturebox width and height. It is the problem. I want to draw the large image withing the with and height of Picturebox width and height. When I try to do that, it is getting the portion of the image.
Probably, I am making a mistake if you know the point, please drop me a few lines of sample code...
Appreciated! Thanks
|
|
|
|
|
Read my previos post again, and take a look at the parameters you use when drawing the image. You will se that you are taking only a part of the watermark image, just as I said.
If you want to draw the entire image, you have to specify the size of the entire image, not a portion of the image the size of the picture box.
---
b { font-weight: normal; }
|
|
|
|
|
Yes! you were right! It is working now!
Thanks a lot!
|
|
|
|
|
Hello
I am learning VB.NET and was toying with the idea of embellishing my database program with Crystal Reports to provide some data reporting facilities.
I was put off by the cost of Crystal, however, and was wondering if there were any free or very low cost report writers that would work with VB.NET. I want to run the reports from within VB, extracting the data either from Access or SQL Server.
If anyone knows of any such report writers, I would be very grateful to hear from them.
Many thanks,
Trimtrom
|
|
|
|
|
Hi. I am writing a data web service in VS 2005 using Ms Sql Server 2005 as data server. I wrote a connection strin gin the web.config file in the area. I used it in the code, but when I invoke it, it doesnt bring up the details. I know there is some data in the table, but it doesnt bring it up via the web service call.
what would I be doing wrong?
|
|
|
|
|
Hi all,
Please help !
Can I pass array parameters to SQL stored Procedure?
Example...
I hava stored procedure like follow
'*********************************************
@Ids varchar(128)
SELECT [LastName] FROM Employees WHERE EmployeeID IN (@Ids)
'*********************************************
When I pass (@Ids = "'1','2','3'") It didn't work.
I don't want directly use commandText.
What should I do?
!Thanks!
!alien!
|
|
|
|
|
No, you can't pass an array to a stored procedure.
You could create a table variable and put the values into that. There is no command to split the string, though, so you would have to do it with string manipulation.
Here's an example of using a table variable, though:
<br />
set nocount on<br />
declare @t table (id varchar(10))<br />
insert into @t values('1')<br />
insert into @t values('2')<br />
insert into @t values('3')<br />
select [LastName] from Employees where EmployeeID in (@t)
Or perhaps the last line has to be:
select [LastName] from Employees where EmployeeID in (select id from @t)
---
b { font-weight: normal; }
-- modified at 5:36 Saturday 4th February, 2006
|
|
|
|
|
Hello!
My aim is to access to scanner and scann the photos or documents via vb.net. Is there any sample code about how to do that in vb.net?
Thanks!
|
|
|
|
|
am porting a vb library to vb.net. The vb library has an external
call to an unmanaged dll.
Existing code:
//External function declaration
Private Declare Function Uncompress& Lib "COMPR.DLL" (ByVal SrcSt$,
ByVal SrcLen&, Dest As Any, ByVal DestLen&)
//Invocation of external function
lReturn = Uncompress(sCompressedResult, Len(sCompressedResult),
aResults(ARRAY_START), ByVal lNewLength)
[where aResults is a double array. The COMPR.Uncompress function
basically uncompress a string 'sCompressedResult' and fills the array
aResults. The array is initialized before calling the external
function]
My understanding is that( Please correct me if I am wrong):
a. The third parameter in declaration 'Dest as Any' means a parameter
of variant type.
b. At invocation, the first element of the double array is passed.
i.e., a pointer to the first element in the double array is passed to
the external function.
c. The Uncompress function expands the compressed data, fills/replaces
the double array with values.
d. The changed values are available to the caller after the Uncompress
function has returned.
Now, I have to call the COMPR.Uncompress method from Vb.Net.
>From browsing the net, I got a lot of information regarding this(
Please correct me if I am wrong):
a. We have to mark the parameter as InAttribute(), Out().
b. We should pin the object so that GC does not change address.
c. We should pass a pointer TO THE FIRST OBJECT OF THE ARRAY to the
native function.
d. Array of type double is non-blittable and so we have to do the
marshaling.
This is the code I wrote:
//External method declaration
<dllimport("compr.dll", entrypoint:="UnCompress" ,=""
setlasterror:="True," charset:="CharSet.Auto," exactspelling:="True,"
callingconvention:="CallingConvention.StdCall)"> _
Public Shared Function UnCompress(ByVal compressedResult As String,
ByVal length As Long, <inattribute(), out(),=""
marshalas(unmanagedtype.struct)=""> ByRef destinationArrayElement As
Object, ByVal newLength As Long) As Long
End Function
//Invocation
'Pin the object
Dim resultsHandle As GCHandle
resultsHandle = GCHandle.Alloc(aResults(ARRAY_START),
GCHandleType.Pinned)
Dim resultsPointer As IntPtr = resultsHandle.AddrOfPinnedObject()
'Invoke
returnValue = UnCompress(sCompressedResult, Len(sCompressedResult),
resultsPointer, newLength)
My problem is that I get the return value correctly, but the array does
not get changed....I get the same data that is passed to the external
function. I think the changes made by the native function is not
persisting.
There is no problem with any of the parameters - I have checked the
same parameters using the existing vb dll and it works. I would like to
know why I dont get the modified array even though I am passing a
pointer to the first element of the array and am pinning the element.
Is this the correct way to marshal (UnmanagedType.struct) and is this
the correct way to pin object?
Any help would be appreciated,
Jim
Jim
|
|
|
|
|
hi every one,
i have values in external array.
Like
str(0)="1234"
str(1)="3 94 34"
i want to send this values into the databse.
all fields in the database are Varchar of size (30).
when i am sending values into the database
like..
insert into tblone(no,no1)values('"& str(0) & "','"& str(1) &"')
i am not getting any problem.
but when i do like this
insert into tblone(no,no1)values("& str(0) & ","& str(1) &")
(removed single quotes) i am getting syntax error.
can any body help me...
raj
|
|
|
|
|
Values for Varchar(),Date etc Fields must be enclosed in Single Quote and for Numeric Field with out Single Quote. It is syntax nothing more.
Regards,
Javed
|
|
|
|
|
As Javed alluded to, inserting string data into a db requires Double Quotes.
-- modified at 4:13 Saturday 4th February, 2006
|
|
|
|
|
Ok I've looked all over the place here and on other forums and surpprizingly I can't find this anywhere.
How do I get the IP Address my browser is at right now and display it in my addressbar (a.k.a TextBox1)?
Thanx for any help you can give me.
|
|
|
|
|
There are two answers to this depending on what you are really looking for:
First, the really ipaddress can be obtained from the DNS object in the framework. you textbox assignment would look something like: text1.value = system.Net.Dns.GetHostByAddress.tostring()
However, if you are doing asp.net, you may really desire what the url adress bar "server" name is for example:
http://www.codeproject.com/script/comments/user_reply.asp
the server name is "www.codeproject.com" which can be applied to a textbox like so: text1.value = page.Request.ServerVariables ("SERVER_NAME")
Hope that helped.
do you need to investigate an online backup[^] company
|
|
|
|
|
Hi Jason,
Yes what I'm looking for is to display the full http:// address that one sees in the browser address bar. I'm creating a very simple web browser and the address bar (Textbox) works fine but when I click on a page link to another link I would like to display the address in the same address bar. Will your second example work for this? And is there more to the code to do this then just putting your example to the textbox I have?
-- modified at 1:35 Saturday 4th February, 2006
|
|
|
|
|
... The second example will only work if you are working in Asp.net (thus providing a webpage to a client through a browser) as you are creating a "simple web browser" I am sure that the second concept will not function like you want.
When the user of your application clicks on a link within the document that you are presenting to them, why not just copy that link to your addressbar_textbox.value?
do you need to investigate an online backup[^] company
|
|
|
|
|
Hi Jason,
After looking around I was able to find exactly what I was looking for. This is what I've got now that works really well.
'Make the Url_Address bar display the url your at.<br />
Private Sub AxWebBrowser_NavigateComplete2(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event) Handles AxWebBrowser.NavigateComplete2<br />
URL_Address.Text = AxWebBrowser.LocationURL<br />
End Sub
Thanks for your help.
|
|
|
|
|
Hi. Is there a way to programmatically copy the contents of a .GIF (or .BMP) into the Clipboard directly from code?
Here is what I want to do:
1) use custom data markers (transparent GIFs) in Excel charts - scatter plot
2) copy contents of .GIF from within MS Access (or Excel) code and then "Paste"
onto/into my data series in Excel chart.
3) I want to avoid code in Excel so that I don't get "Enable macros?"
when I launch from Access (VBA code).
I have MS Access 2000 driving chart templates that reside in Excel (.xls) file. I can manipulate Chart Objects already from Access code, but still learning other "Excel" chart methods/properties.
Excel help says you can use a picture for a custom marker if you copy the image and then paste onto selected data series items - a MANUAL process.
Any help or direction would be appreciated.
Thanks,
Johnny
|
|
|
|
|
What you are looking for is called Excel Automation. Although I have not done exactly what you are talking about here, the Excel DOM (document object model) is extrmely robust, and most likly contains the functions to preform this programmatically.
To start, copy your source excel file, and record your "maunal" orocess as a macro. After stopping the macro, open the VBA editor, within excel, which will have a function that performs your "manual" process. Copy this function into your Access code base. Viola you are 90% done.
Lastly, you will have to create the excel object to run your external macro. A good example is found here: http://www.mvps.org/access/modules/mdl0006.htm[^].
The line discussing the create object code is what you really care about!...
Set objXL = CreateObject("Excel.Application")
Hope this helped
do you need to investigate an online backup[^] company
-- modified at 19:05 Friday 3rd February, 2006
Also take a look at:http://www.codeproject.com/com/ComExcelImages.asp[^]
|
|
|
|
|
Awesome! I totally forgot about (didn't even think of) using "Record Macro" and then see what went on.
Yes, you're right, that will get me the majority of what I need and then the rest is "left to student."
Thanks. (any others?)
Johnny
|
|
|
|
|
I want to show some data in an excel like grid. Is there a table control in vb6?
thanks,
sb
|
|
|
|
|
If I recall correctly, it is called a flex grid.
do you need to investigate an online backup[^] company
|
|
|
|
|
Hi guys
I have a windows form with some textboxes, a datetimepicker, a checkedbox and a numericupdown, all of them binded to a bindingsource, when i add a new record (bindingsource.addnew()) a new row appears and the textboxes are empty (its OK), the datetime picker keeps the value from the previous record, and when i save the record (without modifying the datetimepicker), a new row is inserted but with null value in the datefield, the same happens for the checked box and numericupdown (they kkep the value from the previous record), and if they are not modified, a null value will be inserted.
I know i could assign a value to datetimepicker.value=now, and so on for the other 2 controls, but is there any way to insert records with the values on those controls (no matter if i changed them or not)?
Ive aldo tryed: bindingsource.resetbinding and bindingsource.resetcurrentitem, none of them does what i need
Thanks in advance
|
|
|
|
|