Skip to content

Commit

Permalink
fix bytes to jpeg doc error
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Jun 27, 2024
1 parent 601e075 commit d2af34c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions docs/doc/en/vision/image_ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,10 @@ img = image.Image(320, 240, image.Format.FMT_RGB888)
data = img.to_bytes()
print(type(data), len(data), img.data_size())

img2 = image.Image(320, 240, image.Format.FMT_RGB888, data)
print(img2)
img_jpeg = image.from_bytes(320, 240, image.Format.FMT_RGB888, data)
print(img_jpeg)
img = img_jpeg.to_format(image.Format.FMT_RGB888)
print(img)
```

Here, `to_bytes` returns a new `bytes` object, which is independent memory and does not affect the original image.
Expand Down
6 changes: 4 additions & 2 deletions docs/doc/zh/vision/image_ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,10 @@ img = image.Image(320, 240, image.Format.FMT_RGB888)
data = img.to_bytes()
print(type(data), len(data), img.data_size())

img2 = image.Image(320, 240, image.Format.FMT_RGB888, data)
print(img2)
img_jpeg = image.from_bytes(320, 240, image.Format.FMT_RGB888, data)
print(img_jpeg)
img = img_jpeg.to_format(image.Format.FMT_RGB888)
print(img)
```

这里`to_bytes`获得一个新的`bytes`对象,是独立的内存,不会影响原图。
Expand Down

0 comments on commit d2af34c

Please sign in to comment.