Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add support for png,bmp and other simple image formats #21

Open
BrainStone opened this issue Dec 5, 2014 · 5 comments

Comments

@BrainStone
Copy link

I think it's quite a shame that you can't insert any other images except jpg's.

API wise: It should be fairly easy detecting what kind of image we have from the first few bytes of the image. If not the ending might help. Also adding a new parameter to the image function that would allow to force a specific image format.

@ajstarks
Copy link
Owner

ajstarks commented Dec 5, 2014

Note that the Go API does support PNG.

@BrainStone
Copy link
Author

Since I'm not programming in Go that's not relevant for me.

@TaoHawaii
Copy link

I got this super cool digital dash and now it's going to get much more complicated that it needs to be so I can get that white background to go away... https://photos.app.goo.gl/atHqycZQ7Dmvara02

@SummerSeaSun
Copy link

From README this should be available calling:

VGImage LoadImageFromPNG(filename, imgw, imgh);

I've tried this function but it seems to work with jpeg only:

void image_show(int w, int h, char*filename) {
  int imgw = 1280, imgh = 800;
  VGfloat cx = (w / 2) - (imgw / 2), cy = (h / 2) - (imgh / 2);
  VGfloat ulx = 0, uly = h - imgh;
  VGfloat urx = w - imgw, ury = uly;
  VGfloat llx = 0, lly = 0;
  VGfloat lrx = urx, lry = lly;
  Start(w, h);
  Background(255, 0, 0);
  VGImage LoadImageFromPNG(filename, imgw, imgh);  // won't do anything neither trhow error
//  Image(cx, cy, imgw, imgh, filename); // with jpeg only works
  End();

}

Is this correct?

@paeryn
Copy link

paeryn commented Jan 8, 2020

From README this should be available calling:

VGImage LoadImageFromPNG(filename, imgw, imgh);

I've tried this function but it seems to work with jpeg only:

void image_show(int w, int h, char*filename) {
  int imgw = 1280, imgh = 800;
  VGfloat cx = (w / 2) - (imgw / 2), cy = (h / 2) - (imgh / 2);
  VGfloat ulx = 0, uly = h - imgh;
  VGfloat urx = w - imgw, ury = uly;
  VGfloat llx = 0, lly = 0;
  VGfloat lrx = urx, lry = lly;
  Start(w, h);
  Background(255, 0, 0);
  VGImage LoadImageFromPNG(filename, imgw, imgh);  // won't do anything neither trhow error
//  Image(cx, cy, imgw, imgh, filename); // with jpeg only works
  End();

}

Is this correct?

LoadImageFromPNG() is from my fork Paeryn's fork, although I changed it to CreateImageFromPng() when I standardised the function naming scheme, looks like I missed changing the documentation.
It only loads the image and returns a VGImage handle to it. It doesn't draw it, for that you pass the image to one of the DrawImageAt() functions, then when you are done with the image you have to pass it to OpenVG's vgDestroyImage() to free the memory used.

If you need any other help with my modifications that ajstarks hasn't incorporated back into his then please raise them on my github page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants