|
Ofcourse it is. It's like a Paint routine on a Form, Panel, etc.
Therefore it is not a good idea to put a messagebox in there, just do your coloring.
|
|
|
|
|
Correction: The issue is not the resizing as the resized photos view fine outside of the report. The issue appears moreso to be that when the image is stored in a datatable and put into a crystal report via binary stream, it comes out pixelated. Is there a method to store those in the datatable and transfer them to CR in a less pixelated manner?
I use the following function to resize an image that gets merged into a crystal report to make a photo book.
Private Sub importPhoto(ByVal strFileName As String, ByRef Width As Int32, ByRef Height As Int32, ByVal saveLocation As String, ByRef objDataRow As DataRow)
Dim imgPhoto As New Bitmap(strFileName)
Dim sourceWidth As Int32 = imgPhoto.Width
Dim sourceHeight As Int32 = imgPhoto.Height
Dim sourceX As Int32 = 0
Dim sourceY As Int32 = 0
Dim destX As Int32 = 0
Dim destY As Int32 = 0
Dim nPercent As Single
Dim nPercentW As Single
Dim nPercentH As Single
'If Not File.Exists(saveLocation & "\" & Path.GetFileName(strFileName)) Then
nPercentW = Width / CSng(sourceWidth)
nPercentH = Height / CSng(sourceHeight)
If nPercentH < nPercentW Then
nPercent = nPercentH
destX = System.Convert.ToInt16((Width - (sourceWidth * nPercent)) / 2)
Else
nPercent = nPercentW
destY = System.Convert.ToInt16((Height - (sourceHeight * nPercent)) / 2)
End If
Dim destWidth As Int32 = sourceWidth * nPercent
Dim destHeight As Int32 = sourceHeight * nPercent
Dim bmPhoto As New Bitmap(Width, Height, PixelFormat.Format24bppRgb)
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution)
Dim g As Graphics = Graphics.FromImage(bmPhoto)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.Clear(Color.White)
g.DrawImage(imgPhoto, New Rectangle(destX, destY, destWidth, destHeight), New Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), GraphicsUnit.Pixel)
g.Dispose()
imgPhoto.Dispose()
bmPhoto.Save(saveLocation & "\" & Path.GetFileName(strFileName), Imaging.ImageFormat.Jpeg)
Dim fs As New FileStream(saveLocation & "\" & Path.GetFileName(strFileName), FileMode.Open, FileAccess.Read)
Dim Image(fs.Length - 1) As Byte
fs.Read(Image, 0, Convert.ToInt32(fs.Length))
fs.Close()
objDataRow(11) = Image
File.Delete(saveLocation & "\" & Path.GetFileName(strFileName))
GC.Collect()
'Else
' Dim fs As New FileStream(saveLocation & "\" & Path.GetFileName(strFileName), FileMode.Open, FileAccess.Read)
' Dim Image(fs.Length - 1) As Byte
' fs.Read(Image, 0, Convert.ToInt32(fs.Length))
' fs.Close()
' fs.Dispose()
' objDataRow(11) = Image
' Image = Nothing
' GC.Collect()
'End If
End Sub
Ignoring the commented out parts, the issue is that while the picture does come out at the desired size, it becomes very pixelated. Is this a result of the graphics interpolation mode? Or is there a better method of doing this? The issue is that I get large resolution pictures (2816 x 2112) that end up in a 300 x 200 box in the report. This makes the report giant and time consuming (It is 12,000 pages to begin with) so I shrink the pictures down to a more manageable size in order to speed up performance.
Anyone have an opinion on this?
Cheers, --EA
modified 22-Sep-11 12:21pm.
|
|
|
|
|
Hi,
1.
a 12,000 page report? I assume you're not reading that on a display. When printing (parts of) it, your printer is likely to have say 300dpi, i.e. your 200*300 image will either be smaller than 1 sq.inch, or the printer driver will have to scale it up again.
2.
You have an intermediate step saving bmPhoto to a file.Try using another image format (say bmp) as a test to say whether your bmPhoto itself is of sufficient quality.
BTW: you don't need to save to file, save to a MemoryStream instead.
3.
You're using PixelFormat.Format24bppRgb ; I wouldn't do that, not sure it really matters though.
4.
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution) is something I wouldn't do either. Again not sure it matters.
5.
GC.Collect() is a bad idea; you'd better dispose of disposable objects you no longer need, such as bmPhoto and fs . Then let the GC do its job on its own pace.
|
|
|
|
|
1. These reports are read on screen, not printed. You are correct in that.
2. Thank you, I will implement that.
3. I will try removing that and test the results.
4. I will try that as well.
5. I did let it collect at it's own pace as I like to be gentle, but it ran out of memory as it was storing images faster than the garbage would collect and dispose of unwanted garbage. I will try implementing more dispose patterns.
Thank you for the suggestions, your input is always valuable.
Cheers, --EA
|
|
|
|
|
code peepz,
Why does my vs 2010 is not working anymore???
I googled but nothing had solved the large amount of questions.
I get this error:
Microsoft visual studio had encounter an error and needs to be closed
then i get => mediacontextnotificationwindow : devenv.exe
unknown software error (0xe0434352) location : 0x752dd36f
Can somebody help me out??
Thx in advance
|
|
|
|
|
2 options;
a) uninstall - reinstall
b) reinstall on top
|
|
|
|
|
Hi,
Googling a bit, I found:
1. the possibility you're using a networked disk which happens to have some problems;
2. you're not alone; see here[^] for instance.
|
|
|
|
|
hi all, here my problem is i'm preety new to vb.net programming. but have a little knowledge in vb6 programming.
when form loads in listview are displayed some items.
when you doubleclick selected item, then in the textboxes near listview will display all the information of item selected.
can anyone of you suggest me something else?
till now studied this code :
private sub listview1_dblclick()
for i=1 to listview1.listitems.count
if listview1.listitems(i).selected=true then
dim rs as new adodb.recordset
rs.cursorlocation=aduseclient
rs.open "select * from empdetail where empcode='" & listview1.selecteditem & _
"'",cn
if rs.recordcount>0 then
text1.text=rs!empcode
text2.text=rs!empname
text3.text=rs!empaddress
text4.text=rs!empdesignation
listview1.visible=false
text1.setfocus
rs.close
exit for
else
rs.close
msgbox("......",vbokonly,"")
end if
end if
next
end sub
|
|
|
|
|
|
Hi all,
Could you please help me, If i want to use vb.net to connect with scanner. How should I do? Could you pls provide the sample of it.
Thank so much
|
|
|
|
|
|
Hellow code friends,
I was searching 4 a while after my question but most of the time i find answers with a dataset.
I'm getting my data from a DB (without envolving a dataset).
So
My 4th column or column called opmerkingen is to small in width.
I just want to set my with to 80 or something when my datagridview is loaded.
Can anyone solve my problem in a simple way??
If you answer please do this with an example. there is nothing more clear then an ex...
Thx in advance
Greetings from a n00b
|
|
|
|
|
|
myDGV.Columns[3].Width=80;
or even maybe (once populated):
myDGV.AutoResizeColumns();
|
|
|
|
|
Thx mate
After populating : DataGridView1.AutoResizeColumns()
Did the trick...
greetz
|
|
|
|
|
|
Need an application that opens both the image and the wordfile at a time using VB and anyother....ping me on kantamaneniamarendra@gmail.com
|
|
|
|
|
I assume you're willing to pay for this?
Everything makes sense in someone's mind
|
|
|
|
|
Payment is his email is in the message. Spammers love that
Frazzle the name say's it all
|
|
|
|
|
I'm glad I don't have to type that email out, I can't even say it never mind trying to remember how to spell it!
|
|
|
|
|
I need also a lot of things ....
I cannot remember: What did I before google?
|
|
|
|
|
I need to know the secret of eternal youth, but I won't ping you for it.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Hi there,
I have been searching the web for quite some time now, searching for a way to keep the mouse cursor under a forms control: Not letting the mouse leave the form. I found many answers using the SetCapture function in the user32 lib. However, I cannot get anything to work/the examples used deprecated materials(this was the case most of the time).
Does anybody know how to make a form keep control of the mouse? Examples would be great.
Thank You,
Shawn
PROJECT DESCRIPTION:
I am making a terms and conditions form which will run on start of every computer. I need to make the mouse stay inside the forms control. If the user clicks accept, the form should close; if the user clicks decline, the user should be logged out.
|
|
|
|
|
That's not exactly the most secure solution, considering how many different ways a person can interact with a PC... It'd be very easy to circumvent.
I would suggest instead making your window "system modal", which basically means the user can't interact with anything else until your window is closed.
|
|
|
|
|
That's a nice idea but System Modal dialogs died with Windows 9x.
|
|
|
|