How to save part of a bitmap

MaxApps

Active Member
Licensed User
Longtime User
Hi

I am trying to save a part of a bitmap, but I cant get it right.
The following program almost does it, but there is one BIG problem.
The part of the image, that I am saving, should be 96dip x 64dip. That small part does get saved, but it gets filled with black around it and the bitmap ends up with 480x465.
Can someone tell me what is wrong?

canvas1.Initialize(Panel1)
Dim Bitmap1 As Bitmap
Bitmap1.Initialize(File.DirAssets, "1.jpg")
Dim DestRect As Rect
DestRect.Initialize(0dip, 0dip, 96dip, 64dip)

Dim name As String
Dim Out As OutputStream

Dim SrcRect As Rect
Dim Nummer As Int
SrcRect.Initialize(0, 0, 96, 64)
DestRect.Top = 0dip
DestRect.Bottom = 64dip
DestRect.Left = 0dip
DestRect.Right = 96dip
canvas1.DrawBitmap(Bitmap1, SrcRect, DestRect)
name="part1.png"
Out = File.OpenOutput(File.DirRootExternal, name, False)
canvas1.Bitmap.WriteToStream(Out, 100, "PNG")
Out.Close


Kind regards
Jakob
 

mkvidyashankar

Active Member
Licensed User
Longtime User
updated file

Hi klaus

I replace the library with touchImageView

Attached the zip file. Please look in to the module and guide me.

The main purpose of this module is to save selected part ( panned and zoomed part) of the image which is displayed on the imageview.

If there is any other way please tell me, i will replace this whole thing.

Thanks in advance
 
Upvote 0
Top