Android Open Source - sdl_tester_android Sdl Image Item

From Project

Back to project page sdl_tester_android.


The source code is released under:

Copyright (c) 2014, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are m...

If you think the Android project sdl_tester_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.livio.sdl;
//  w  w w  . java2  s . co  m
import java.util.Comparator;


import com.livio.sdl.utils.AndroidUtils;
import com.livio.sdl.utils.SdlUtils;
import com.smartdevicelink.proxy.rpc.Image;
import com.smartdevicelink.proxy.rpc.enums.FileType;
import com.smartdevicelink.proxy.rpc.enums.ImageType;

 * Represents an SDL image object.  This includes the bitmap object itself, 
 * a filename to be used on SDL and an ImageType representing the type of image
 * we're looking at.
 * @author Mike Burke
public class SdlImageItem {
  public static class SdlImageItemComparator implements Comparator<SdlImageItem>{
    public int compare(SdlImageItem lhs, SdlImageItem rhs) {
      return lhs.getImageName().compareTo(rhs.getImageName());

  private Bitmap bitmap;
  private String imageName;
  private FileType imageType;
  public SdlImageItem(Bitmap bitmap, String imageName, FileType imageType) {
    this.bitmap = bitmap;
    this.imageName = imageName;
    this.imageType = imageType;

  public Bitmap getBitmap() {
    return bitmap;

  public String getImageName() {
    return imageName;
  public FileType getImageType(){
    return imageType;
  public Image toImage(){
    CompressFormat format = SdlUtils.convertImageTypeToCompressFormat(imageType);
    Image image = new Image();
    image.setBulkData(AndroidUtils.bitmapToRawBytes(bitmap, format));
    return image;
  public static Image toImage(SdlImageItem item){
    return item.toImage();


Java Source Code List