Forum > General

how to use the units -no information about this

<< < (3/8) > >>

engkin:

--- Quote from: alaa123456789 on January 14, 2022, 11:46:52 am ---RSVG unit how to use it to show svg file on the form

--- End quote ---

rsvg is a partial header for librsvg,  version 2 specifically.

I found version 2.2 on my laptop, inside GIMP binary folder.

Made a copy of rsvg file into a new project folder and changed the name of the library to match the one I have. I also defined DYNLIB to get it to work with the dll.

I found the man pages for librsvg, not long after that I did a quick test:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses...  ,rsvg  ,gdk2pixbuf;...procedure Test_rsvg(fn:string; Canvas:TCanvas);var  e:PGError;  h:PRsvgHandle;  buf:PGdkPixbuf;  channels,bits_per_sample,width,height,rowstride:LongInt;  colorspace:TGdkColorspace;  alpha:boolean32;  pixels:Pguchar;  y,x:integer;  pb:PByte;begin  rsvg_init;   //read a file  h:=rsvg_handle_new_from_file(pchar(fn),e);  if h=nil then  begin    LogLn('rsvg_handle_new_from_file: ',e^.message);    exit;  end;   //Get pix  buf:=rsvg_handle_get_pixbuf(h);   //Get pix info  colorspace:=gdk_pixbuf_get_colorspace(buf);  channels:=gdk_pixbuf_get_n_channels(buf);  alpha:=gdk_pixbuf_get_has_alpha(buf);  bits_per_sample:=gdk_pixbuf_get_bits_per_sample(buf);  pixels:=gdk_pixbuf_get_pixels(buf);  width:=gdk_pixbuf_get_width(buf);  height:=gdk_pixbuf_get_height(buf);  rowstride:=gdk_pixbuf_get_rowstride(buf);   //Draw pix  pb:=pixels;  for y:=0 to height-1 do  begin    for x:=0 to width-1 do    begin      Canvas.Pixels[x,y]:=RGBToColor((pb+0)^,(pb+1)^,(pb+2)^);      inc(pb,4);    end;  end;   //clean up  rsvg_handle_close(h,e);  rsvg_term;end;
This to get you started. I tried it on one file and it seems right.

Thaddy:
Also have a look at the language reference guide:
https://www.freepascal.org/docs-html/current/ref/refse112.html#x233-25700016.2

And tis
https://www.thoughtco.com/anatomy-of-delphi-unit-for-beginners-4091943
Note that is for delphi but covers FPC too. *.dpr  equals *.lpr. The unit parts work out of the box in {$mode delphi}

alaa123456789:

--- Quote from: dbannon on January 15, 2022, 01:34:19 am ---
--- Quote from: alaa123456789 on January 14, 2022, 01:02:45 pm ---THE SPECIFIC QUESTION IS THIS
--- Quote ---RSVG unit how to use it to show svg file on the form OR TIMAGE
--- End quote ---
....

--- End quote ---

Are you aware that all caps is regarded as shouting ?  I'll assume you are not so aware.

--- End quote ---
i don't like to argue with you about capital and small letter meaning, but i never been mean to anyone
thanks for your advise , the topic is how to use the units as i said for example Rsvg but there are many units is not having information , i know about bgra component , but to learn how to use the units with ide,fpc is much better and useful

thanks

dbannon:

--- Quote from: alaa123456789 on January 15, 2022, 12:33:33 pm ---...... but there are many units is not having information

--- End quote ---

Yes, I agree. The "getting a first start" information is missing in a lot of places. I have been trying to get some interest in indexing and documenting the existing set of examples (there are well over 200 but hard to find the one you want) in https://forum.lazarus.freepascal.org/index.php/topic,57680.0.html but sadly I am not seeing any interest and will abandon the idea tomorrow.


--- Quote from: alaa123456789 on January 15, 2022, 12:33:33 pm ---.... i know about bgra component , but to learn how to use the units with ide,fpc is much better and useful

--- End quote ---

bgra is  FPC just as much as Rsvg is. And probably bgra is more widely used and better supported.  I have only used it once in a small tryout that I abandoned because I was disturbed about how much it enlarged my binary. But it was definitely quite easily used with a most things fairly obvious. Given, as I said, its widely used, heavily discussed and under active development, might be a good choice.

Davo

SymbolicFrank:
typing the function name and pressing F1 helps if you have the help installed. Otherwise, first google to find which function you need (mostly fro the forum here) and then google for that function name to see in which unit it resides.

It's advisable to do that anyway if you're not sure, because things get added and move around. Like, the units that hold the same functions, but for UTF-8, or functions that don't rely on Windows, etc.

I tend to google first if I think something is difficult and could be much simpler, before I use the complex one or build it myself.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version