保存位图而不损失质量(渐变背景)

时间:2019-01-12 06:41:02

标签: android-studio bitmap

我创建了一个形成线性渐变背景的位图。我正在尝试将其保存到设备的存储器中,但是保存的图像质量很低。

保存位图图像的代码:

import React from "react";
import { connect } from "react-redux";

import { deleteItem } from "./action";
import { getItemById } from "./selectors";

interface StateProps {
  title: string;
}

interface DispatchProps {
  onDelete: () => any;
}

interface OwnProps {
  id: string;
}

export type SampleItemProps = StateProps & DispatchProps & OwnProps;

export const SampleItem: React.SFC<SampleItemProps> = props => (
  <div>
    <div>{props.title}</div>
    <button onClick={props.onDelete}>Delete</button>
  </div>
);

// You can either use an explicit mapStateToProps...
const mapStateToProps = (state: RootState, ownProps: OwnProps) : StateProps => ({
  title: getItemById(state, ownProps.id)
});

// Ommitted mapDispatchToProps...

// ... and infer the types from connects arguments ...
export default connect(mapStateToProps, mapDispatchToProps)(SampleItem);

// ... or explicitly type connect and "inline" map*To*.
export default connect<StateProps, DispatchProps, OwnProps, RootState>(
  (state, ownProps) => ({
    title: getItemById(state, ownProps.id)
  }),
  (dispatch, ownProps) => ({
    onDelete: () => dispatch(deleteItem(ownProps.id))
  })
)(SampleItem);

图片应该是这样的

Image should be like this

但是就是这样

But it's like this

我做错什么了吗?

先谢谢大家! :)

1 个答案:

答案 0 :(得分:0)

似乎insertImage方法仅存储原始位图的缩略图。这是一个可能有帮助的解决方案:

How to insert high quality Bitmap image in android into Gallery