I have an app I created a while back that uses TiffPictureMBS to merge barcodes into printing plate file bitmap TIFFs that are 97349 w X 75600 h. I have recently been given a requirement to rotate the merged TIFF files 270 degree after the barcode merge. I have tried several ways to do this that all result in failure. The most promising method appeared to be to to first merge the files to PictureMBS and use PictureMBS.Rotate270. this works fine with a grayscale image but fails with a bitmap image. My assumption is that this is because there is not an available ImageFormat for bitmap in PictureMBS and I am forced to use Graysale, (PictureMBS.ImageFormatG) . Even so, what’s weird is if I don’t rotate and just pass though PictureMBS by commenting out the Rotate270 the bitmap works. I’m looking for suggestions and or alternative to rotate a bitmap file and retain the 1bit depth.
Here is some test code I’m using, (that does not include the barcode images being merged into the memoryblock), that gives me the gobledygook output on rotating a bitmap:
[code]Public Sub RotateTiff()
Dim desc,err As String
Dim PlateFile As FolderItem = GetOpenFolderItem(FileTypes1.ImageTiff)
Dim DestFldr As FolderItem = SpecialFolder.Desktop
Dim n As Integer
Dim oldname,newname,nameparts() As String
oldname = PlateFile.Name
nameparts = Split(oldname,".")
For n = 0 To UBound(nameparts) -1
If n = 0 Then
newname = nameparts(n)
Else
newname = newname + “.” + nameparts(n)
End If
Next
n = UBound(nameparts)
newname = newname + “.new.” + nameparts(n)
Dim PlateFileNew As FolderItem = SpecialFolder.Desktop.Child(newname)
Dim PlateTIFF As New TiffPictureMBS
Dim PlateTIFFNew As New TiffPictureMBS
If PlateTIFF.Open(PlateFile) Then
If PlateTIFFNew.Create(PlateFileNew) Then
Dim d As Date
Dim y,m,dy,hh,mm,ss As String
d = New Date
y = Right(Str(d.Year),2)
m = Format(d.Month,"0#")
dy = Format(d.Day,"0#")
hh =Format(d.Hour,"0#")
mm = Format(d.Minute,"0#")
ss =Format(d.Second,"0#")
PlateTIFFNew.Height = PlateTIFF.Height
PlateTIFFNew.Width = PlateTIFF.Width
PlateTIFFNew.RowsPerStrip = PlateTIFF.RowsPerStrip
PlateTIFFNew.PlanarConfig = PlateTIFF.PlanarConfig
PlateTIFFNew.Photometric = PlateTIFF.Photometric
PlateTIFFNew.BitsPerSample = PlateTIFF.BitsPerSample
PlateTIFFNew.SamplesPerPixel = PlateTIFF.SamplesPerPixel
PlateTIFFNew.SampleFormat = PlateTIFF.SampleFormat
PlateTIFFNew.FillOrder = PlateTIFF.FillOrder
PlateTIFFNew.Orientation = PlateTIFF.Orientation
PlateTIFFNew.ResolutionUnit = PlateTIFF.ResolutionUnit
PlateTIFFNew.VerticalResolution = PlateTIFF.VerticalResolution
PlateTIFFNew.VerticalPosition = PlateTIFF.VerticalPosition
PlateTIFFNew.HorizontalResolution = PlateTIFF.HorizontalResolution
PlateTIFFNew.HorizontalPosition = PlateTIFF.HorizontalPosition
PlateTIFFNew.Compression = PlateTIFF.Compression
PlateTIFFNew.Copyright = PlateTIFF.Copyright
PlateTIFFNew.DateTime = y + ":" + m + ":" + dy + " " + hh + ":" + mm + ":" + ss
PlateTIFFNew.HostComputer = PlateTIFF.HostComputer
PlateTIFFNew.ImageDescription = PlateTIFF.ImageDescription
PlateTIFFNew.Make = PlateTIFF.Make
PlateTIFFNew.Model = PlateTIFF.Model
PlateTIFFNew.Software = PlateTIFF.Software
Dim PlateMemoryBlock As MemoryBlock = NewMemoryBlock(PlateTIFF.BytesPerRow)
Dim p As New PictureMBS(PlateTIFF.Width, PlateTIFF.Height, PictureMBS.ImageFormatG)
For i as Integer = 0 to PlateTIFF.Height - 1
// read
Call PlateTIFF.Scanline(PlateMemoryBlock, i)
p.RowInFormat(i, p.ImageFormatG) = PlateMemoryBlock
Next
p = p.Rotate270
For i as Integer = 0 to PlateTIFF.Height - 1
// write
PlateTIFFNew.Scanline(i) = p.RowInFormat(i, p.ImageFormatG)
Next
PlateTIFF.Close
PlateTIFFNew.Close
Else
// Error
MsgBox("The PlateTIFFNew could not be created. ")
End If
Else
// Error
MsgBox("The Plate TIFF could not be opened. ")
End If
End Sub
[/code]
By commenting out p = p.Rotate270
I can use the above code and the new TIFF looks identical to the original TIFF
With p = p.Rotate270
uncommented the resulting bitmap is garbage
But it works correctly with a grayscale image