openvg icon indicating copy to clipboard operation
openvg copied to clipboard

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

Open BrainStone opened this issue 9 years ago • 5 comments

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.

BrainStone avatar Dec 05 '14 00:12 BrainStone

Note that the Go API does support PNG.

ajstarks avatar Dec 05 '14 01:12 ajstarks

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

BrainStone avatar Dec 05 '14 01:12 BrainStone

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

TaoHawaii avatar Jan 07 '18 11:01 TaoHawaii

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?

SummerSeaSun avatar Jan 07 '20 11:01 SummerSeaSun

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.

paeryn avatar Jan 08 '20 13:01 paeryn