kopia lustrzana https://github.com/olgamiller/SSTVEncoder2
Moved text size factor calculation out from LabelCollection, write to file also text size factor
MainActivity: Load TextOverlayTemplate before ModeSize is changed in CropViewpull/3/head
rodzic
d67719abd8
commit
0e5df3571d
|
@ -288,7 +288,7 @@ public class CropView extends ImageView {
|
|||
super.onSizeChanged(w, h, old_w, old_h);
|
||||
if (mModeSize != null)
|
||||
mOutputRect = Utility.getEmbeddedRect(w, h, mModeSize.width(), mModeSize.height());
|
||||
mLabelCollection.update(w, h);
|
||||
mLabelCollection.update(w, h, Utility.getTextSizeFactor(w, h));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -67,13 +67,16 @@ public class MainActivity extends AppCompatActivity {
|
|||
setContentView(R.layout.activity_main);
|
||||
mCropView = (CropView) findViewById(R.id.cropView);
|
||||
mEncoder = new Encoder(new MainActivityMessenger(this), getProgressBar(), getProgressBar2());
|
||||
|
||||
mSettings = new Settings(this);
|
||||
mSettings.load();
|
||||
|
||||
mTextOverlayTemplate = new TextOverlayTemplate();
|
||||
mTextOverlayTemplate.load(mCropView.getLabels(), mSettings.getTextOverlayFile());
|
||||
|
||||
IModeInfo mode = mEncoder.getModeInfo();
|
||||
mCropView.setModeSize(mode.getModeSize());
|
||||
setTitle(mode.getModeName());
|
||||
mSettings = new Settings(this);
|
||||
mSettings.load();
|
||||
mTextOverlayTemplate = new TextOverlayTemplate();
|
||||
mTextOverlayTemplate.load(mCropView.getLabels(), mSettings.getTextOverlayFile());
|
||||
loadImage(getIntent());
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ import java.io.IOException;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import om.sstvencoder.Utility;
|
||||
|
||||
public class LabelCollection {
|
||||
private class Size {
|
||||
private float mW, mH;
|
||||
|
@ -55,7 +53,7 @@ public class LabelCollection {
|
|||
mPreviousY = 0f;
|
||||
}
|
||||
|
||||
public void update(float w, float h) {
|
||||
public void update(float w, float h, float textSizeFactor) {
|
||||
if (mScreenSize != null) {
|
||||
float x = (w - mScreenSize.width()) / 2f;
|
||||
float y = (h - mScreenSize.height()) / 2f;
|
||||
|
@ -63,16 +61,11 @@ public class LabelCollection {
|
|||
label.offset(x, y);
|
||||
}
|
||||
mScreenSize = new Size(w, h);
|
||||
mTextSizeFactor = getTextSizeFactor(w, h);
|
||||
mTextSizeFactor = textSizeFactor;
|
||||
for (LabelContainer label : mLabels)
|
||||
label.update(mTextSizeFactor, w, h);
|
||||
}
|
||||
|
||||
private float getTextSizeFactor(float w, float h) {
|
||||
Rect bounds = Utility.getEmbeddedRect((int) w, (int) h, 320, 240);
|
||||
return 0.1f * bounds.height();
|
||||
}
|
||||
|
||||
public void draw(Canvas canvas) {
|
||||
for (LabelContainer label : mLabels)
|
||||
label.draw(canvas);
|
||||
|
@ -154,6 +147,7 @@ public class LabelCollection {
|
|||
{
|
||||
writer.write("width", mScreenSize.width());
|
||||
writer.write("height", mScreenSize.height());
|
||||
writer.write("factor", mTextSizeFactor);
|
||||
writer.beginArray("labels");
|
||||
{
|
||||
for (LabelContainer label : mLabels)
|
||||
|
@ -169,6 +163,7 @@ public class LabelCollection {
|
|||
{
|
||||
float w = reader.readFloat();
|
||||
float h = reader.readFloat();
|
||||
float textSizeFactor = reader.readFloat();
|
||||
reader.beginArray();
|
||||
{
|
||||
while (reader.hasNext()) {
|
||||
|
@ -178,7 +173,7 @@ public class LabelCollection {
|
|||
}
|
||||
}
|
||||
reader.endArray();
|
||||
update(w, h);
|
||||
update(w, h, textSizeFactor);
|
||||
}
|
||||
reader.endObject();
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@ public final class Utility {
|
|||
return rect;
|
||||
}
|
||||
|
||||
static float getTextSizeFactor(int w, int h) {
|
||||
return 0.1f * (Utility.getEmbeddedRect(w, h, 320, 240).height());
|
||||
}
|
||||
|
||||
static String createMessage(Exception ex) {
|
||||
String message = ex.getMessage() + "\n";
|
||||
for (StackTraceElement el : ex.getStackTrace())
|
||||
|
|
Ładowanie…
Reference in New Issue