#include "img.h"
#include <stdio.h>
#include <stdlib.h>
#include "webp/encode.h"
MyImage *createMyImage(int width, int height) {
MyImage *img;
img = (MyImage*)malloc(sizeof(MyImage)); img->width = width; img->height = height; img->data = (unsigned char *)malloc(sizeof(unsigned char)*3*width*height); return img;
}
void freeMyImage(MyImage *img) {
free(img->data);
free (img);
}
unsigned char *getPixel(MyImage *img, int x, int y) {
int k;
k = 3*(img->width*y+x); return img->data+k;
}
void setPixel(MyImage *img, int x, int y,
unsigned char r, unsigned char g, unsigned char b) {
unsigned char *pixel;
pixel = getPixel(img, x, y); pixel[0] = r; pixel[1] = g; pixel[2] = b; } void saveImage(MyImage *img, char *filename) { int filesize; unsigned char *compressed_data; FILE *webp_file; filesize = WebPEncodeRGP(img->data, img->height, img->width*3, 95, &compressed_data); webp_file = fopen(filename, "wb"); fwrite(compressed_data, sizeof(unsigned char), filesize, webp_file); fclose(webp_file); WebPFree(compressed_data); } void fillColor(MyImage *img, unsigned char r, unsigned char g, unsigned char b) { int x, y; for (y=0; y<img->height; y++) { for (x=0; x<img->width; x++) { setPixel(img, x, y, r, g, b); } } }
別のヘッダーファイルとCソースファイル一つずつあります。
このコードをコンパイルするとこのようなエラーが出てきます。これは"webp/encode"のパッケージがダウンロードされていないと解釈しているのですが、間違いですか。一応libwebp-1.2.2-windows-x64はダウンロードしています。しかし、これにwebp/encodeのファイルはbinやlibを探しても見当たりません。またこれが正常にリンクされているのかもわかりません。あまり参考に資料などがなかったのでとりあえずMinGWのファイルに突っ込んでみたり、ユーザーに突っ込んでみたり、環境変数に設定した見たりしたのですがうんともすんとも言いません。まずこのエラーはlibwebpがしっかりリンクされていないのが原因ですか。またそうでしたらリンクのさせ方を教えていただきたいです。
回答3件
あなたの回答
tips
プレビュー