为什么在读取png图像时会出现垃圾值

时间:2015-12-22 09:42:28

标签: java image-processing

我正在为每个像素写一个值为15的PNG图像。当我读到书面图像时,而不是15,我得到了垃圾值。为什么会这样? 由于我想恢复相同的值,我选择了无损的PNG格式。我仍然得到垃圾值。 这是代码。

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"Cell";

    UitableviewcellTableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];

    if(position == indexPath.row){
        int row;
        value = [NSString stringWithFormat:@"%d",[value intValue] + [_countingarray[row] intValue]];
        Cell.nameLabel.text = value;
        NSLog(@"%@", value);
    }else{
        Cell.nameLabel.text = @"value";
    }
    NSLog(@"Position :- %ld   %d", (long)indexPath.row, position);

    return Cell;
}

仅供参考,我已经打印了五个值来检查我是否会得到15。但输出是 -16777216 -16777216 -16777216 -16777216 -16777216
-16777216 -16777216 -16777216 -16777216 -16777216
-16777216 -16777216 -16777216 -16777216 -16777216
-16777216 -16777216 -16777216 -16777216 -16777216
-16777216 -16777216 -16777216 -16777216 -16777216

1 个答案:

答案 0 :(得分:1)

您正在撰写byte并阅读int。试试这个 -

System.out.print((byte)img1.getRGB(p,j) + "\t");
相关问题