Click here to Skip to main content
15,905,028 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: open a ms word file in a richtextbox Pin
Dave Kreskowiak15-Apr-09 5:32
mveDave Kreskowiak15-Apr-09 5:32 
GeneralRe: open a ms word file in a richtextbox Pin
0x3c015-Apr-09 5:40
0x3c015-Apr-09 5:40 
GeneralRe: open a ms word file in a richtextbox Pin
Luc 64801115-Apr-09 5:48
Luc 64801115-Apr-09 5:48 
GeneralRe: open a ms word file in a richtextbox Pin
Dave Kreskowiak15-Apr-09 6:02
mveDave Kreskowiak15-Apr-09 6:02 
AnswerRe: open a ms word file in a richtextbox Pin
marclenoir200515-Apr-09 9:03
marclenoir200515-Apr-09 9:03 
GeneralRe: open a ms word file in a richtextbox Pin
0x3c015-Apr-09 10:28
0x3c015-Apr-09 10:28 
GeneralRe: open a ms word file in a richtextbox Pin
Zaegra15-Apr-09 10:29
Zaegra15-Apr-09 10:29 
QuestionGDI Quality Pin
smallzoo15-Apr-09 3:25
smallzoo15-Apr-09 3:25 
This is really frustrating. I produced some graphs using GDI and vb.net and on the screen they look fine. When you print them off on a black and white printer they look fine BUT on a colour printer the quality is really bad. you can see lines in the colours which is just not acceptable..

I have included the sample code below. I have tried changing to bmp, png etc and it makes not difference.. what am I missing ?.. i can send a copy of the picture produced if anyone can help or you can just copy the code and try running it..

Thanks

Peter


----- Default.aspx

]]>





<title>Untitled Page















----- Default.aspx.vb

Imports System.Configuration
Imports System.Drawing.Printing
Imports System.Drawing
Imports System.Drawing.Imaging

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim brshObj As SolidBrush = New SolidBrush(Color.White)
Dim new_font As New Font("Tahoma", 6)
Dim x, y, i As Integer
Dim MTmonths(12) As String
Dim iloop, rec, lastx, lasty1, lasty2 As Integer
Dim starty, endy, ydiv, stepdiv, yaxis As Double
Dim j

Dim allMonths As String = "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"
Dim monthNames(12) As String
monthNames = Split(allMonths, ",")

Dim LY_Yield(12) As Double
Dim TY_Yield(12) As Double
Dim TYield As String = "20.42,18,15.6,17.22,17.31,19.14,16.52,18.25,18.52,0,0,0"
Dim LYield As String = "22.16,20.59,16.72,17.3,18.35,18.24,19.24,19.62,17.62,16.56,14.53,16.08"
Dim sTYield(13) As String
Dim sLYield(13) As String
sTYield = Split(TYield, ",")
sLYield = Split(LYield, ",")

For rec = 1 To 12
LY_Yield(rec) = CDbl(sLYield(rec - 1))
TY_Yield(rec) = CDbl(sTYield(rec - 1))
MTmonths(rec) = monthNames(rec - 1)
Next


Dim maxy As Double
Dim miny As Double
Dim m1, m2 As Double
maxy = -9999999
miny = 9999999

For iloop = 1 To 12
m1 = TY_Yield(iloop) : m2 = LY_Yield(iloop)
If m1 <> -9999 And m1 <> 0 Then
If m1 > maxy Then maxy = m1
If m1 < miny Then miny = m1
End If
If m2 <> -9999 And m2 <> 0 Then
If m2 > maxy Then maxy = m2
If m2 < miny Then miny = m2
End If
Next

Dim objBitmap As Bitmap = New Bitmap(340, 230)
Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)
Dim bmpNew As Bitmap = New Bitmap(objBitmap.Width, objBitmap.Height)
'bmpNew.SetResolution(280, 220)
Dim oGraphic As Graphics = Graphics.FromImage(bmpNew)
Dim rectObjB As Rectangle = New Rectangle(-50, -50, objBitmap.Width + 50, objBitmap.Height + 50)
Dim rectObj As Rectangle = New Rectangle(0, 0, objBitmap.Width, objBitmap.Height)
oGraphic.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
oGraphic.FillRectangle(brshObj, rectObj)

Dim pn1 As Pen = New Pen(Color.Red, 1)
Dim pn2 As Pen = New Pen(Color.RoyalBlue, 3)
Dim pnax As Pen = New Pen(Color.Black, 2)

oGraphic.DrawLine(pnax, 20, 210, 340, 210)
oGraphic.DrawLine(pnax, 20, 210, 20, 20)
objBitmap.RotateFlip(RotateFlipType.RotateNoneFlipY)
Dim TextBrsh As Brush = New SolidBrush(Color.Black)
Dim TextFont As New Font("Arial", 8, FontStyle.Regular)

For i = 1 To 12
x = ((i / 12) * 300) - 5
oGraphic.TextRenderingHint = Text.TextRenderingHint.AntiAliasGridFit
oGraphic.DrawString(MTmonths(i), TextFont, TextBrsh, x, 210)
Next


Dim aPoints(11) As Point
Dim bPoints(11) As Point

endy = maxy + (maxy * 20 / 100) : starty = miny - (miny * 20 / 100) : endy = Math.Floor(endy + 0.5) : starty = Math.Floor(starty + 0.5) : stepdiv = Math.Round((endy - starty) / 8, 0)
ydiv = endy - starty

For yaxis = starty To endy Step stepdiv
y = (-1 * ((yaxis - endy) / ydiv * 190))
oGraphic.DrawLine(Pens.Gray, 20, y + 20, 340, y + 20)
oGraphic.TextRenderingHint = Text.TextRenderingHint.AntiAliasGridFit
oGraphic.DrawString(yaxis, TextFont, TextBrsh, 1, y + 10)
Next

i = 1 : j = endy : lastx = 20 : lasty1 = 200 : lasty2 = 200

For iloop = 1 To 12
x = (i / 12) * 300
j = LY_Yield(iloop)
If j <> -9999 Then
y = (-1 * ((j - endy) / ydiv * 190))
Else
y = lasty1
x = lastx
End If
aPoints(i - 1).X = x : aPoints(i - 1).Y = y
lasty1 = y

j = TY_Yield(iloop)
If j <> -9999 Then
y = (-1 * ((j - endy) / ydiv * 190))
Else
y = lasty2
x = lastx
End If
bPoints(i - 1).X = x : bPoints(i - 1).Y = y
lasty2 = y
i = i + 1
lastx = x
Next


oGraphic.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias


' new compression technique
Dim Codec, JPEGCodec As System.Drawing.Imaging.ImageCodecInfo
Dim EncParams As System.Drawing.Imaging.EncoderParameters
Dim QualitySetting As Long = 100L
For Each Codec In System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders
If Codec.MimeType = "image/jpeg" Then
JPEGCodec = Codec
Exit For
End If
Next
EncParams = New System.Drawing.Imaging.EncoderParameters(1)
EncParams.Param(0) = New System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, QualitySetting)
'MyImage.Save(ImageFileName, JPEGCodec, EncParams)

'Dim offset As Integer = 1
'Dim segments As Integer = 3
'Dim tension As Single = 0.5F
'oGraphic.DrawCurve(pn1, aPoints, offset, segments, tension)
'oGraphic.DrawCurve(pn2, bPoints, offset, segments, tension)

oGraphic.DrawCurve(pn1, aPoints, 0.5F)
oGraphic.DrawCurve(pn2, bPoints, 0.5F)
objBitmap = bmpNew
objBitmap.Save(Server.MapPath("~/GT1.jpg"), ImageFormat.Jpeg)
objBitmap.Save(Server.MapPath("~/GT2.jpg"), JPEGCodec, EncParams)
objBitmap.Dispose()


End Sub
End Class
AnswerRe: GDI Quality Pin
Dave Kreskowiak15-Apr-09 6:23
mveDave Kreskowiak15-Apr-09 6:23 
GeneralRe: GDI Quality Pin
smallzoo15-Apr-09 9:31
smallzoo15-Apr-09 9:31 
GeneralRe: GDI Quality Pin
Luc Pattyn15-Apr-09 11:11
sitebuilderLuc Pattyn15-Apr-09 11:11 
GeneralRe: GDI Quality Pin
Dave Kreskowiak15-Apr-09 12:12
mveDave Kreskowiak15-Apr-09 12:12 
GeneralRe: GDI Quality Pin
smallzoo15-Apr-09 21:55
smallzoo15-Apr-09 21:55 
GeneralRe: GDI Quality Pin
Dave Kreskowiak16-Apr-09 1:37
mveDave Kreskowiak16-Apr-09 1:37 
QuestionActiveX Pin
siva45515-Apr-09 3:14
siva45515-Apr-09 3:14 
AnswerRe: ActiveX Pin
Yusuf21-Apr-09 5:25
Yusuf21-Apr-09 5:25 
QuestionUpdating Data set to Database Pin
specialdreamsin15-Apr-09 2:06
specialdreamsin15-Apr-09 2:06 
AnswerRe: Updating Data set to Database Pin
0x3c015-Apr-09 2:13
0x3c015-Apr-09 2:13 
AnswerRe: Updating Data set to Database Pin
Vimalsoft(Pty) Ltd15-Apr-09 3:07
professionalVimalsoft(Pty) Ltd15-Apr-09 3:07 
QuestionHow Font is related to Character set Pin
sunil goyalG15-Apr-09 1:36
sunil goyalG15-Apr-09 1:36 
AnswerRe: How Font is related to Character set Pin
0x3c015-Apr-09 2:11
0x3c015-Apr-09 2:11 
GeneralRe: How Font is related to Character set Pin
sunil goyalG15-Apr-09 2:23
sunil goyalG15-Apr-09 2:23 
GeneralRe: How Font is related to Character set Pin
Dave Kreskowiak15-Apr-09 2:26
mveDave Kreskowiak15-Apr-09 2:26 
AnswerRe: How Font is related to Character set Pin
Andy Missico15-Apr-09 2:25
Andy Missico15-Apr-09 2:25 
GeneralRe: How Font is related to Character set Pin
sunil goyalG15-Apr-09 3:00
sunil goyalG15-Apr-09 3:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.