mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Rename save_to_memory for consistency.
This commit is contained in:
@@ -23,7 +23,7 @@ Options :: image.Options
|
|||||||
RGB_Pixel :: image.RGB_Pixel
|
RGB_Pixel :: image.RGB_Pixel
|
||||||
RGBA_Pixel :: image.RGBA_Pixel
|
RGBA_Pixel :: image.RGBA_Pixel
|
||||||
|
|
||||||
save_to_memory :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) {
|
save_to_buffer :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) {
|
||||||
context.allocator = allocator
|
context.allocator = allocator
|
||||||
|
|
||||||
if img == nil {
|
if img == nil {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//+build js
|
//+build js
|
||||||
package qoi
|
package qoi
|
||||||
|
|
||||||
save :: proc{save_to_memory}
|
save :: proc{save_to_buffer}
|
||||||
|
|
||||||
load :: proc{load_from_bytes, load_from_context}
|
load :: proc{load_from_bytes, load_from_context}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package qoi
|
|||||||
import "core:os"
|
import "core:os"
|
||||||
import "core:bytes"
|
import "core:bytes"
|
||||||
|
|
||||||
save :: proc{save_to_memory, save_to_file}
|
save :: proc{save_to_buffer, save_to_file}
|
||||||
|
|
||||||
|
|
||||||
save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) {
|
save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) {
|
||||||
@@ -13,7 +13,7 @@ save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocato
|
|||||||
out := &bytes.Buffer{}
|
out := &bytes.Buffer{}
|
||||||
defer bytes.buffer_destroy(out)
|
defer bytes.buffer_destroy(out)
|
||||||
|
|
||||||
save_to_memory(out, img, options) or_return
|
save_to_buffer(out, img, options) or_return
|
||||||
write_ok := os.write_entire_file(output, out.buf[:])
|
write_ok := os.write_entire_file(output, out.buf[:])
|
||||||
|
|
||||||
return nil if write_ok else .Unable_To_Write_File
|
return nil if write_ok else .Unable_To_Write_File
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ GA_Pixel :: image.GA_Pixel
|
|||||||
RGB_Pixel :: image.RGB_Pixel
|
RGB_Pixel :: image.RGB_Pixel
|
||||||
RGBA_Pixel :: image.RGBA_Pixel
|
RGBA_Pixel :: image.RGBA_Pixel
|
||||||
|
|
||||||
save_to_memory :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) {
|
save_to_buffer :: proc(output: ^bytes.Buffer, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) {
|
||||||
context.allocator = allocator
|
context.allocator = allocator
|
||||||
|
|
||||||
if img == nil {
|
if img == nil {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//+build js
|
//+build js
|
||||||
package tga
|
package tga
|
||||||
|
|
||||||
save :: proc{save_to_memory}
|
save :: proc{save_to_buffer}
|
||||||
load :: proc{load_from_bytes, load_from_context}
|
load :: proc{load_from_bytes, load_from_context}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package tga
|
|||||||
import "core:os"
|
import "core:os"
|
||||||
import "core:bytes"
|
import "core:bytes"
|
||||||
|
|
||||||
save :: proc{save_to_memory, save_to_file}
|
save :: proc{save_to_buffer, save_to_file}
|
||||||
|
|
||||||
save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) {
|
save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocator := context.allocator) -> (err: Error) {
|
||||||
context.allocator = allocator
|
context.allocator = allocator
|
||||||
@@ -12,7 +12,7 @@ save_to_file :: proc(output: string, img: ^Image, options := Options{}, allocato
|
|||||||
out := &bytes.Buffer{}
|
out := &bytes.Buffer{}
|
||||||
defer bytes.buffer_destroy(out)
|
defer bytes.buffer_destroy(out)
|
||||||
|
|
||||||
save_to_memory(out, img, options) or_return
|
save_to_buffer(out, img, options) or_return
|
||||||
write_ok := os.write_entire_file(output, out.buf[:])
|
write_ok := os.write_entire_file(output, out.buf[:])
|
||||||
|
|
||||||
return nil if write_ok else .Unable_To_Write_File
|
return nil if write_ok else .Unable_To_Write_File
|
||||||
|
|||||||
Reference in New Issue
Block a user