loadbitmapsample not scaling to set size

harlechguy

Member
Licensed User
Longtime User
Evening all, have a small app that allows users to select pages from manuals by clicking on thumbnails and then scrolling through the manual by clicking arrows

the below code is not behaving as I would expect - namely the loadbitmapsample is not scaling the bitmap to fit within the specified dimensions - instead the bitmap is unscaled and chopped off at the edges.

I have attached the complete code in a text file

any ideas much appreciated - thanks




<
Sub updateimage(clickedthumb2a)
Dim tc As ImageView
Dim ths1 As ths
Dim sv1 As ScrollView
Dim pn1 As Panel
Dim cursor1 As Cursor

clearpanel2

If minthumb < clickedthumb2 Then
ImageView4.Visible = True
ImageView4.enabled = True
Else
ImageView4.visible = False
ImageView4.enabled = False
End If
If maxthumb > clickedthumb2 Then
ImageView3.visible = True
ImageView3.enabled = True
Else
ImageView3.visible = False
ImageView3.enabled = False
End If


cursor1 = sql1.ExecQuery2("select Manual, Section, Page, ID from Items where ID= ?", Array As String(clickedthumb2a))
cursor1.Position=0
manuala = cursor1.GetString("Manual")
manuala = manuala.Replace(" ","_")
sectiona = cursor1.GetString("Section")
sectiona = sectiona.Replace(" ","_")
page = cursor1.GetString("Page")
page=page.Replace(" ","_")
folderb = manuala & "/" & sectiona & "/" & page & ".jpeg"
'Log(folderb)


ths1.folderb = folderb
ths1.indexb = clickedthumb2a

cursor1.Close

If tc.IsInitialized = True Then tc.RemoveView
sv1.Initialize(1115)
pn1 = sv1.Panel
sv1.BringToFront
pn1.BringToFront

Panel2.AddView(sv1,0,0,750,470)


tc.Initialize("thumbclick")
tc.bitmap= LoadBitmapSample(File.DirRootExternal & "/docbrowser", folderb, 750, 1110)
pn1.AddView(tc,5,5,740,1100)
tc.Tag = ths1
End Sub
 
Last edited:

harlechguy

Member
Licensed User
Longtime User
Hi NJDude, thanks for reply, have attached the project as text file as too large to attach as a zip. Is that ok?

the project references a database (all working fine) am just missing something with the bitmap element

their are two subs that are very similar - the first works great the second has the issue with bitmap sizing - they both call the same bitmap resources at different stages of the program

sub thumbclick_click

and

Sub updateimage(clickedthumb2a)
 
Upvote 0

harlechguy

Member
Licensed User
Longtime User
Erel, thanks for the gravity.fill tip - works spot on.

Any idea why the gravity.fill is required in some instances and not others?

my two subs are very similar - as shown below
I would be interested for my understanding

thanks

1st sub
<------------------------------------------------
Sub thumbclick_click
Dim tc As ImageView
Dim ths1 As ths
Dim sv1 As ScrollView
Dim pn1 As Panel

ImageView3.visible = False
ImageView3.enabled = False
ImageView4.visible = False
ImageView4.enabled = False

clearpanel2
tc = Sender

ths1=tc.Tag
clickedthumb = ths1.folderb
clickedthumb2 = ths1.indexb


If thumbflag = 0 Then

addthumbs(databholder,dataaholder)
thumbflag = 1
Return
End If

If thumbflag = 1 Then
If tc.IsInitialized = True Then tc.RemoveView
sv1.Initialize(1115)
pn1 = sv1.Panel
sv1.BringToFront
pn1.BringToFront

Panel2.AddView(sv1,0,0,750,470)
tc.bitmap= LoadBitmapSample(File.DirRootExternal & "/docbrowser", clickedthumb, 750, 1110)
pn1.AddView(tc,5,5,740,1100)

thumbflag = 0
If thumbcount <>0 Then
checkimagecount(databholder,dataaholder)
End If

End If


End Sub
>---------------------------------------------------------
2nd sub

<-----------------------------------------------------------
Sub updateimage(clickedthumb2a)
Dim tc As ImageView
Dim ths1 As ths
Dim sv1 As ScrollView
Dim pn1 As Panel
Dim cursor1 As Cursor

clearpanel2

If minthumb < clickedthumb2 Then
ImageView4.Visible = True
ImageView4.enabled = True
Else
ImageView4.visible = False
ImageView4.enabled = False
End If
If maxthumb > clickedthumb2 Then
ImageView3.visible = True
ImageView3.enabled = True
Else
ImageView3.visible = False
ImageView3.enabled = False
End If


cursor1 = sql1.ExecQuery2("select Manual, Section, Page, ID from Items where ID= ?", Array As String(clickedthumb2a))
cursor1.Position=0
manuala = cursor1.GetString("Manual")
manuala = manuala.Replace(" ","_")
sectiona = cursor1.GetString("Section")
sectiona = sectiona.Replace(" ","_")
page = cursor1.GetString("Page")
page=page.Replace(" ","_")
folderb = manuala & "/" & sectiona & "/" & page & ".jpeg"


ths1.folderb = folderb
ths1.indexb = clickedthumb2a

cursor1.Close

If tc.IsInitialized = True Then tc.RemoveView
sv1.Initialize(1115)
pn1 = sv1.Panel
sv1.BringToFront
pn1.BringToFront

Panel2.AddView(sv1,0,0,750,470)


tc.Initialize("thumbclick")
tc.bitmap= LoadBitmapSample(File.DirRootExternal & "/docbrowser", folderb, 750, 1110)
tc.Gravity=Gravity.FILL
pn1.AddView(tc,5,5,740,1100)
tc.Tag = ths1
End Sub
>--------------------------------------------------------
 
Upvote 0
Top