99 lines
3.6 KiB
Java
99 lines
3.6 KiB
Java
package org.jmrtd.lds;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import net.sf.scuba.tlv.TLVInputStream;
|
|
import net.sf.scuba.tlv.TLVOutputStream;
|
|
import o.C15109ghW;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class DisplayedImageInfo extends AbstractImageInfo {
|
|
public static final int DISPLAYED_PORTRAIT_TAG = 24384;
|
|
public static final int DISPLAYED_SIGNATURE_OR_MARK_TAG = 24387;
|
|
private static final long serialVersionUID = 3801320585294302721L;
|
|
private int displayedImageTag;
|
|
|
|
public DisplayedImageInfo(int i, byte[] bArr) {
|
|
super(i);
|
|
this.displayedImageTag = getDisplayedImageTagFromType(i);
|
|
setMimeType(getMimeTypeFromType(i));
|
|
setImageBytes(bArr);
|
|
}
|
|
|
|
public DisplayedImageInfo(InputStream inputStream) throws IOException {
|
|
readObject(inputStream);
|
|
}
|
|
|
|
@Override // org.jmrtd.lds.AbstractImageInfo
|
|
protected void readObject(InputStream inputStream) throws IOException {
|
|
TLVInputStream tLVInputStream = inputStream instanceof TLVInputStream ? (TLVInputStream) inputStream : new TLVInputStream(inputStream);
|
|
int b = tLVInputStream.b();
|
|
this.displayedImageTag = b;
|
|
if (b != 24384 && b != 24387) {
|
|
StringBuilder sb = new StringBuilder("Expected tag 0x5F40 or 0x5F43, found ");
|
|
sb.append(Integer.toHexString(this.displayedImageTag));
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
int typeFromDisplayedImageTag = getTypeFromDisplayedImageTag(b);
|
|
setType(typeFromDisplayedImageTag);
|
|
setMimeType(getMimeTypeFromType(typeFromDisplayedImageTag));
|
|
readImage(tLVInputStream, tLVInputStream.c());
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: protected */
|
|
@Override // org.jmrtd.lds.AbstractImageInfo
|
|
public void writeObject(OutputStream outputStream) throws IOException {
|
|
TLVOutputStream tLVOutputStream = outputStream instanceof TLVOutputStream ? (TLVOutputStream) outputStream : new TLVOutputStream(outputStream);
|
|
tLVOutputStream.d(getDisplayedImageTagFromType(getType()));
|
|
writeImage(tLVOutputStream);
|
|
tLVOutputStream.c();
|
|
}
|
|
|
|
@Override // org.jmrtd.lds.AbstractImageInfo, org.jmrtd.lds.ImageInfo
|
|
public long getRecordLength() {
|
|
return C15109ghW.b(getDisplayedImageTagFromType(getType())).length + C15109ghW.a(r0).length + getImageLength();
|
|
}
|
|
|
|
private static String getMimeTypeFromType(int i) {
|
|
if (i == 0 || i == 1) {
|
|
return ImageInfo.JPEG_MIME_TYPE;
|
|
}
|
|
if (i == 2) {
|
|
return ImageInfo.WSQ_MIME_TYPE;
|
|
}
|
|
StringBuilder sb = new StringBuilder("Unknown type: ");
|
|
sb.append(Integer.toHexString(i));
|
|
throw new NumberFormatException(sb.toString());
|
|
}
|
|
|
|
private static int getDisplayedImageTagFromType(int i) {
|
|
if (i == 0) {
|
|
return 24384;
|
|
}
|
|
if (i == 1) {
|
|
return 24387;
|
|
}
|
|
StringBuilder sb = new StringBuilder("Unknown type: ");
|
|
sb.append(Integer.toHexString(i));
|
|
throw new NumberFormatException(sb.toString());
|
|
}
|
|
|
|
private static int getTypeFromDisplayedImageTag(int i) {
|
|
if (i == 24384) {
|
|
return 0;
|
|
}
|
|
if (i == 24387) {
|
|
return 1;
|
|
}
|
|
StringBuilder sb = new StringBuilder("Unknown tag: ");
|
|
sb.append(Integer.toHexString(i));
|
|
throw new NumberFormatException(sb.toString());
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public int getDisplayedImageTag() {
|
|
return this.displayedImageTag;
|
|
}
|
|
}
|