|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Rotating ImagesThe following Code works with .Net framework, but not with Mono! What is wrong. The images is saved but without rotation!
Friend Sub RotateFlipImage(ByRef LVitem As ListViewItem, ByVal RFT As RotateFlipType, Optional ByVal jpgCompression As Long = -1) Const CodeLoc As String = className & ".RotateFlipImage" Dim BAKPath As String Dim path As String = LVitem.Name Dim EncVal As System.Drawing.Imaging.EncoderValue Dim Action As String, ActionType As clsUndo.EnumActionType Dim blnRenamed As Boolean BAKPath = ClsGlobal.GetBackPath(path) gStatus = CodeLoc & " Start" Try Try gStatus = CodeLoc & " Rename File" My.Computer.FileSystem.RenameFile(path, IO.Path.GetFileName(BAKPath)) blnRenamed = True Catch ex As IOException Throw New ApplicationException("Error Renaming File " & path, ex) End Try Using img As New Bitmap(BAKPath) 'img = Image.FromFile(path & ".BAK" & i) Select Case RFT Case RotateFlipType.Rotate180FlipNone EncVal = Imaging.EncoderValue.TransformRotate180 Action = LibPhotoPrinter.ClsGlobal.GetLang("Rotate180", "Drehen 180") ActionType = clsUndo.EnumActionType.Rotate180 Case RotateFlipType.Rotate270FlipNone EncVal = Imaging.EncoderValue.TransformRotate270 Action = LibPhotoPrinter.ClsGlobal.GetLang("RotateLeft", "Drehen90-") ActionType = clsUndo.EnumActionType.RotateLeft Case RotateFlipType.Rotate90FlipNone EncVal = Imaging.EncoderValue.TransformRotate90 Action = LibPhotoPrinter.ClsGlobal.GetLang("RotateRight", "Drehen90+") ActionType = clsUndo.EnumActionType.RotateRight Case Else Throw New ApplicationException("RFT not implemented") End Select gStatus = CodeLoc & " RotateImg: " & path & " " & EncVal.ToString & " " & " Action: " & Action modGrafics.RotateImg(img, path, EncVal) frmMain.AddToUndo(path, BAKPath, Action, ActionType, frmMain.Listview.SelLVItem.Index, frmMain.Listview.SelImagePath) blnRenamed = False 'img.Dispose() 'img = Nothing 'GC.Collect() End Using Catch ex As Exception clsErrorHandling.HandleError(ex, "modGrafics.RotateFlipImage") If blnRenamed Then My.Computer.FileSystem.RenameFile(BAKPath, IO.Path.GetFileName(path)) End If End Try gStatus = CodeLoc & " Finished" End Sub Friend Sub RotateImg(ByRef pic As Image, ByVal FileName As String, ByVal Value As EncoderValue, Optional ByVal BakUpFileName As String = "", Optional ByRef p As Imaging.PropertyItem = Nothing) 'Dim pic As Image Const Codeloc As String = ClassName & ".RotateImg" gStatus = Codeloc & " Start" Dim Enc As Encoder = Encoder.Transformation Dim EncParms As EncoderParameters = New EncoderParameters(1) Dim EncParm As EncoderParameter Dim CodecInfo As ImageCodecInfo = LibPhotoPrinter.clsGrafics.GetEncoderByExt(IO.Path.GetExtension(FileName)) '// load the image to change 'pic = Image.FromFile(FileName) EncParm = New EncoderParameter(Enc, Value) EncParms.Param(0) = EncParm If p Is Nothing = False Then p.Value = BitConverter.GetBytes(CShort(1)) pic.SetPropertyItem(p) End If gStatus = Codeloc & " Save file " & FileName & " CodecInfo " & CodecInfo.ToString & " Parms " & EncParm.ToString pic.Save(FileName, CodecInfo, EncParms) End Sub Regards Hans |
|
|
Re: Rotating ImagesHi,
Please file a bug report in bugzilla.novell.com with a complete (compilable) test case. Rolf > -----Original Message----- > From: mono-vb-bounces@... [mailto:mono-vb- > bounces@...] On Behalf Of Easy_Rider9999 > Sent: domingo, 16 de agosto de 2009 11:42 > To: mono-vb@... > Subject: [mono-vb] Rotating Images > > > The following Code works with .Net framework, but not with Mono! What > is > wrong: > > Friend Sub RotateImg(ByRef pic As Image, ByVal FileName As String, > ByVal > Value As EncoderValue, Optional ByVal BakUpFileName As String = "", > Optional > ByRef p As Imaging.PropertyItem = Nothing) > 'Dim pic As Image > Const Codeloc As String = ClassName & ".RotateImg" > gStatus = Codeloc & " Start" > > Dim Enc As Encoder = Encoder.Transformation > Dim EncParms As EncoderParameters = New EncoderParameters(1) > Dim EncParm As EncoderParameter > Dim CodecInfo As ImageCodecInfo = > LibPhotoPrinter.clsGrafics.GetEncoderByExt(IO.Path.GetExtension(FileNam > e)) > > > '// load the image to change > 'pic = Image.FromFile(FileName) > > > > > EncParm = New EncoderParameter(Enc, Value) > EncParms.Param(0) = EncParm > If p Is Nothing = False Then > p.Value = BitConverter.GetBytes(CShort(1)) > pic.SetPropertyItem(p) > End If > gStatus = Codeloc & " Save file " & FileName & " CodecInfo " & > CodecInfo.ToString & " Parms " & EncParm.ToString > pic.Save(FileName, CodecInfo, EncParms) > > End Sub > > > Regards Hans > -- > View this message in context: http://www.nabble.com/Rotating-Images- > tp24991859p24991859.html > Sent from the Mono - VB mailing list archive at Nabble.com. > > _______________________________________________ > Mono-vb mailing list > Mono-vb@... > http://lists.ximian.com/mailman/listinfo/mono-vb _______________________________________________ Mono-vb mailing list Mono-vb@... http://lists.ximian.com/mailman/listinfo/mono-vb |
|
|
Re: Rotating ImagesI have done this before with my other program Repetit.Net.T.SQLITE. My program and source code is available at SourceForge: http://sourceforge.net/projects/photoprinter/ if anybody likes to test it. Regards Hans |
| Free embeddable forum powered by Nabble | Forum Help |