lib/sogoumap2pdf/image_to_pdf.rb in sogoumap2pdf-0.0.1 vs lib/sogoumap2pdf/image_to_pdf.rb in sogoumap2pdf-0.0.2
- old
+ new
@@ -28,14 +28,14 @@
ny0=y/256
nxn=(x+w)/256+1
nyn=(y+h)/256+1
delta_x=x-nx0*256
delta_y=y-ny0*256
- p "x #{x}"
- p "y #{y}"
- p "delta_x #{delta_x}"
- p "delta_y #{delta_y}"
+ # p "x #{x}"
+ # p "y #{y}"
+ # p "delta_x #{delta_x}"
+ # p "delta_y #{delta_y}"
ci=ImageList.new # image list to hold results
page=Rectangle.new( 0, 0, 0, 0)
for i in nx0..nxn
for j in ny0..nyn
@@ -69,22 +69,19 @@
resimg=ci.mosaic
end
return resimg.crop(SouthWestGravity,delta_x,delta_y,w,h,true)
end
- def perfect_fit(nh256,nw256,r,c)
+ def perfect_fit(w,h,r,c)
+ @page_width=w
+ @page_height=h
@row=r
@column=c
@tumb_x=@page_width*256/(c*@page_width-(c-1)*@page_overlap)
@tumb_y=@page_height*256/(r*@page_height-(r-1)*@page_overlap)
@big_img_width,@big_img_height=c*@page_width-(c-1)*@page_overlap, r*@page_height-(r-1)*@page_overlap
-
- if nh256==0 then
- return c*@page_width-(c-1)*@page_overlap, r*@page_height-(r-1)*@page_overlap
- else
- return c*nw256*256, r*nh256*256
- end
+ return c*@page_width-(c-1)*@page_overlap, r*@page_height-(r-1)*@page_overlap
end
def create_pages(g)
# get the size of the image
size_x=@big_img_width
size_y=@big_img_height
@@ -216,11 +213,10 @@
j*@page_width/cols, @page_height-i*@page_height/rows,
(j+1)*@page_width/cols, @page_height-(i+1)*@page_height/rows)
end
end
end
- def save()
- #@pdf.save_as("map4eeepc.pdf")
- @pdf.save_as(ARGV[5])
+ def save(save_file)
+ @pdf.save_as(save_file)
end
end
end