MCPcopy Create free account
hub / github.com/BombusMod/BombusMod / getPhotoMIMEType

Method getPhotoMIMEType

src/main/java/VCard/VCard.java:214–249  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

212
213//#if FILE_IO
214 public String getPhotoMIMEType() {
215 if (photo.length==1) return null;
216 try {
217 if (photo[0]==(byte)0xff &&
218 photo[1]==(byte)0xd8 &&
219 ((photo[6]==(byte)'J' &&
220 photo[7]==(byte)'F' &&
221 photo[8]==(byte)'I' &&
222 photo[9]==(byte)'F')
223 ||
224 (photo[6]==(byte)'E' &&
225 photo[7]==(byte)'x' &&
226 photo[8]==(byte)'i' &&
227 photo[9]==(byte)'f')
228 )
229 )
230 return "image/jpeg";
231
232 if (photo[0]==(byte)0x89 &&
233 photo[1]==(byte)'P' &&
234 photo[2]==(byte)'N' &&
235 photo[3]==(byte)'G')
236 return "image/png";
237
238 if (photo[0]==(byte)'G' &&
239 photo[1]==(byte)'I' &&
240 photo[2]==(byte)'F')
241 return "image/gif";
242
243 if (photo[0]==(byte)'B' &&
244 photo[1]==(byte)'M')
245 return "image/x-ms-bmp";
246 } catch (Exception e) {}
247 //System.out.println("unknown MIME type");
248 return null;
249 }
250
251 public String getFileType() {
252 String MIMEtype=getPhotoMIMEType();

Callers 2

setPhotoTypeMethod · 0.95
getFileTypeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected